Linux-Modem-Sharing(1).pdf

(18 KB) Pobierz
Modem Sharing mini-HOWTO
Modem Sharing mini−HOWTO
Friedemann Baitinger
fb@baiti.net
2001−08−22
Revision History
Revision v1.12
2001−08−22
Revised by: gjf
Corrected author's email
Revision v1.11
2001−07−12
Revised by: aeg
Converted to DocBook SGML
Revision v1.10
1999−09−11
Revised by: fb
Added "Feedback from the Users" section
Revision v1.01
1997−06−12
Revised by: fb
Converted source to HTML
Describes how to setup a Linux system to share a modem with other systems over a TCP/IP network.
Modem Sharing mini−HOWTO
Table of Contents
1. Legal Notice. ....................................................................................................................................................1
2. The Server Side. ..............................................................................................................................................2
2.1. Masqdialer Installation. .....................................................................................................................3
2.2. Masqdialer Configuration. ................................................................................................................3
3. The Client Side. ...............................................................................................................................................4
4. Security Considerations. .................................................................................................................................5
5. Examples. .........................................................................................................................................................6
6. Feedback From Users. ....................................................................................................................................7
i
184432147.002.png
1. Legal Notice
Copyright © 1997 Friedemann Baitinger. This document may be distributed only subject to the terms and
conditions set forth in the GNU Free Documentation License at < http://www.gnu.org/copyleft/fdl.html > .
>
1. Legal Notice
1
184432147.003.png
2. The Server Side
It is assumed that the server is a Linux system with either:
· an 'isdn4linux'−emulated modem mapped to a /dev/ttyIx device
a modem attached to a /dev/ttySx device
·
The easiest setup I can think of uses a five lines perl script to implement a modem daemon in
/usr/sbin/modemd :
#!/usr/bin/perl
select((select(STDOUT), $| = 1)[$[]);
select((select(STDIN), $| = 1)[$[]);
exec 'cu −s 115200 −l /dev/ttyS1';
die '$0: Cant exec cu: $!\n';
The modem daemon is started by the inetd process if a client connects to the appropriate port as described
below. The modemd simply connects the socket handle with STDIN and STDOUT of the cu command and
lets cu handle the actual modem device.
The existence of the modem daemon must be made known to the inetd process by updating its configuration
file, usually /etc/inetd.conf like:
#
# modem daemon
#
modem stream tcp nowait root /usr/sbin/tcpd /usr/sbin/modemd /dev/ttyS1
In order to make this work, an entry to /etc/services needs to be added like:
modem 2006/tcp modemd
This associates a symbolic name with an explicit port, 2006 in the example. The portnumber could be any
number not already assigned to an existing service. After these changes have been made, a signal must be
sent to the inetd process in order to let inetd re−read and process its configuration file:
bash# ps | grep inetd
194 ? S 0:00 /usr/sbin/inetd
bash# kill −HUP 194
Now the server side is ready to accept requests from clients. The correct function can be verified by:
bash$ telnet localhost modem
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
You are now connected to the modem. You can now issue AT commands in order to verify the setup:
atz
2. The Server Side
2
184432147.004.png
Modem Sharing mini−HOWTO
atz
OK
ati1
ati1
Linux ISDN
OK
^]
telnet>quit
bash$
Instead of using the Perl script as a modem server, there is also a program named Masqdialer available at
With Masqdialer you can export any number of modems connected to your server to any host that can
connect the server via TCP/IP on a given port with a binary data stream.
2.1. Masqdialer Installation
Before compiling check config.h for compile time options:
· set the path for the lock file to your liking
set the path for the config file to your liking
·
Do make all .
Copy the binaries ( mserver and tcpconn ) into a suitable directory such as /usr/local/sbin/. Copy
mserver.conf into the path that you specified in config.h .
Masqdialer could be started from one of your system startup scripts. A simple /usr/local/sbin/mserver will
run it as a daemon.
2.2. Masqdialer Configuration
A line in mserver.conf could look like this:
5800 /dev/ttyS1 115200,8,N,1 *.foo.org,192.168.2.1
which would mean that a modem connected to /dev/ttyS1 can be connected via port 5800 from anywhere
in the domain foo.org and from host 192.168.2.1. Any other hosts are rejected. Pitfall: If you don't specify
hosts then ANY host will be allowed to connect. The serial line settings are fixed and cannot be changed from
the client side. You can export several modems on a single port. Masqdialer only locks the modem devices by
use of UUCP style lock files when they are actually in use thus allowing other programs to take advantage of
them.
2.1. Masqdialer Installation
3
184432147.005.png 184432147.001.png
Zgłoś jeśli naruszono regulamin