[H-GEN] dialup under linux
Tony Nugent
tony at linuxworks.com.au
Wed Mar 12 03:26:25 EST 2003
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
[ this reply turned into something more than I originally
expected, I hope people here will find it useful. ]
[ please don't quote this entire 200-odd line message if you post
a reply... be nice and edit it approprately. Thanks. ]
On Wed Mar 12 2003 at 13:08, Harry Phillips wrote:
> Shaun Nykvist wrote:
>
> > cannot access the internet. I think the issue lies with the fact that
> > he has already got a default gateway set from his static settings.
> > can someone offer some guidance on this issue
> >
> Check the '/etc/ppp/options' file for the 'defaultroute' line if it's
> not there, add it.
Indeed, that is exactly what needs to be done.
But be aware that there are potential problems if you do it like
that... all options used in that file effectively become "global"
(ie, they will be used for every invocation of pppd).
For many cases this is fine, eg, as a quick hack or for use on a
"static" box using only a single dialup connection.
But it is very awkward if you want some flexability with how you use
ppp connections, and a real problem if you use multiple ISPs or want
to use dialups in different ways per-connection. For example:
- the user name, password and telephone number will be different
for the various ISPs you may want to use.
- it is easy to become a ppp dialin server (details below)...
you might want to be able to easily allow someone to dial in and
connect to you at home, peer to peer. If you have a cable or adsl
connection for internet access, then this allows your friend to
use it too.
Put into /etc/ppp/options only those options that will be used with
every connection, and then for each connection you want to
configure, put the nesessary options into separate files in the
directory /etc/ppp/peers/
When you do this, you can use any of these specific connections
simply by using a "call" option to pppd, followed by the name of the
config file in the peers/ directory.
For example, you may use various dialups like this:
pppd call myisp
pppd call bigpond
pppd call harry
pppd call server
... where there are the appropriate files in /etc/ppp/peers/ that
contain all the magic necessary to configure these various
connections. "harry" might be a mate to whom you may want to make
an occasional dialup connection. Just plug a new config file in,
and use it.
(Note that "call" expects the file to be in /etc/ppp/peers/ It is
also possible to use "pppd file /path/to/optionsfile", but this time
specifying the full pathname to the location of that options file
anywhere on the system).
Ok, here are some configuration examples (indented for readability).
NB: here /dev/modem is a symlink to the real serial port that has
the modem attached to it, eg, /dev/ttyS0 This is useful if you
change the modem's serial port... only one change is needed to make
it work (point /dev/modem to /dev/ttyS1), while the config files
don't need to be touched.
# - /etc/ppp/options -
# generic global options here only
lock
debug
# - end -
This conf file will make a connection by envoking "pppd call myisp":
# - /etc/ppp/peers/myisp -
# - dialup ppp client configuration -
# - nb: multiple options can be put onto the one line -
/dev/modem 115200 modem crtscts
# - connect script to use to make the modem connection -
connect '/usr/sbin/chat -v -f /etc/ppp/chat.script -T12345678'
# logfile /var/log/pppd-myisp.log
user <<dialup username in /etc/ppp/{chap,pap}.secrets>>
defaultroute
# - note that this will create /etc/ppp/resolv.conf -
# - ip-up script will need to use this to modify /etc/resolv.conf -
# - ip-down script can be used to put bac original /etc/resolv.conf -
usepeerdns
# - negotiate compression, nb: may need to tweak modules.conf -
bsdcomp 15,15 deflate 15,15 predictor1
ipcp-accept-local ipcp-accept-remote
ipparam myisp
# - end -
If you want to act as dialup server, then this is a bit more
complicated - but not that much more. The basic setup described
here would do the trick for most people...
# -- snip from /etc/inittab --
# - run mgetty listening for incoming calls on /dev/modem -
S0:34:respawn:/sbin/mgetty -x 3 -D -n 2 modem
# -- end snip --
Running mgetty from init will maintain the dialin capability on a
permanent basis. If you want to become a dialin server on one-off
occasion, then you can run mgetty directly from a root shell - in
which case the mgetty process will exit when the connection
terminates (and not re-newed).
As it turns out, there are three possible places to put
server-specific options for pppd, so some variations are possible
with how configuring the connection could be done:
- pass (some) options to pppd via mgetty's command-line invocation
- use a "call" parameter to force mgetty's invocation to use a
config file in /etc/ppp/peers/ eg, "pppd call server".
- create a file called /etc/ppp/options.<serial port> which pppd
will use on a per-port basis (optional, if it exists).
# - snip from /etc/mgetty+sendfax/login.conf -
# - runs pppd on incoming connections -
# /AutoPPP/ - a_ppp /usr/sbin/pppd call server
# - Note the options used here to pppd when run via mgetty -
/AutoPPP/ - a_ppp /usr/sbin/pppd auth +chap -pap login debug
# - end snip -
# - /etc/ppp/peers/server -
# - used with mgetty from /etc/mgetty+sendfax/login.conf -
auth +chap -pap login debug
# - end -
When pppd is envoked as a server, it will use an options file called
/etc/ppp/options.<serialport> Since we are using /dev/modem here,
then the relevant file would be /etc/ppp/options.modem. If you use
/dev/ttyS0 then it would be /etc/ppp/options/ttyS0, etc. You just
need to be consistent.
The IPs used below are examples only. Note that:
- the server itself has an IP of 192.168.1.1/24 on its eth0 interface
- the 192.168.1/24 network is thus being used for the LAN connected
on that interface
- the dialup client is allocated a (permanent) IP that is within
the same c-class network address space used on the LAN
- the dialup server is acting as a DNS and WINS (samba) server for
the client
- the server may be also be the default route for internet
connectivity for the LAN, acting as masquerading router; it will
also need to masquerade for the ppp client(s). (ref: iptables)
- this describes a simple static setup only. ISPs usually use a
radius server for authentication and configuration, but this is
outside the scope of the current discussion.
# - /etc/ppp/options.modem -
# - act as a simple dialup ppp server -
# - modem on /dev/modem -
crtscts modem
# logfile /var/log/pppd.server
# - use chap authentication only -
auth refuse-pap require-chap
# - force login to use system password -
login
# - networking: IPs, dns, wins server -
# - local server IP : remote client IP -
192.168.1.1:192.168.1.240
netmask 255.255.255.0
ms-dns 192.168.1.1
ms-wins 192.168.1.1
# - remote client will have an IP belonging to the local network -
# - this allows the client to "join" the LAN by using arp/routing -
proxyarp
# - ignore badly configured clients trying to use ipx -
noipx
# - persist for ages -
# idle 864000
# - persist for 3 hours -
idle 1800
# - end -
If you had more modems attached to the second serial port or a pci
serial card, then you would create multipe options.ttyS* files for
each one.
Note that you might need to run /usr/bin/setserial, eg, from an init
script, to enable and pre-configure the actual serial ports
(essential for pci/multiport serial cards).
Apologies in advance for any typos, errors or admissions in any of
the above.
Any questions? - "It's all in the documentation" :)
Have fun with this!
Cheers
Tony
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'. See http://www.humbug.org.au/
More information about the General
mailing list