Setup wvdial to dial your ISP ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before we can attempt to get dial-on-demand working, we need to make sure that we can dial up our ISP. The easiest way to make a configuration is to use wvdialconf. Don't worry about any warnings about not finding /etc/wvdial.conf. This is normal and 'wvdialconf' will create it. [root@router:~> # wvdialconf /etc/wvdial.conf Scanning your serial ports for a modem. ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 4800 baud ttyS0<*1>: ATQ0 V1 E1 -- OK ttyS0<*1>: ATQ0 V1 E1 Z -- OK ttyS0<*1>: ATQ0 V1 E1 S0=0 -- OK ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- ERROR ttyS0<*1>: Modem Identifier: ATI -- 128K ttyS0<*1>: Speed 9600: AT -- OK ttyS0<*1>: Speed 19200: AT -- OK ttyS0<*1>: Speed 38400: AT -- OK ttyS0<*1>: Speed 57600: AT -- OK ttyS0<*1>: Speed 115200: AT -- OK ttyS0<*1>: Max speed is 115200; that should be safe. ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK Found a modem on /dev/ttyS0. /etc/wvdial.conf: Can't read config file /etc/wvdial.conf: No such file or directory Modem configuration written to /etc/wvdial.conf. ttyS0: Speed 115200; init "ATQ0 V1 E1 S0=0 &C1 &D2" This produced the following /etc/wvdial.conf . You will have a similar file. [Dialer Defaults] Modem = /dev/ttyS0 Baud = 115200 Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 ISDN = 0 Modem Type = Analog Modem ; Phone = ; Username = ; Password = You can now fill in your ISP's phone number, your username and password. You should now be able to run wvdial and connect to the Internet. Type wvdial and you should see several lines scroll past and will stop after starting pppd. To stop the connection, press - C. Refer to the wvdial homepage if you can not connect. Some things to check are that wvdialconf detected the right modem init strings for your modem. You should be able to find sensible init strings by looking at any MS Windows inf files for your modem. www.56k.com may be of some help. I recommend that you re-arrange your wvdial.conf to separate the modem configuration from any ISP account details. Read the wvdial documentation for more information. Here is a similar file to my own. [Dialer Defaults] Modem = /dev/ttyS0 Baud = 115200 Init1 = ATZ Init2 = AT &FE0x7 Init3 = AT B40 Init4 = AT S84.4=1 Init5 = AT S7=60 S50=0 L1 M1 &K3 &K44 &H3 Init6 = AT S87.2=0 Dial Command = ATDI Auto DNS = off ; use analogue modem [Dialer modem] Modem = /dev/ttyS1 Baud = 115200 Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0 Init3 = Init4 = Init5 = Init6 = ; display modem information [Dialer info] Init9 = AT&V ; Prevent wvdial reconnecting after being disconnected [Dialer noreconnect] Auto Reconnect = off ; BT Connect Lite service [Dialer ConnectLite] ; BT are stupid. See the man page for details Stupid Mode = on Phone = 08089933024 Username = user@btconnect.com Password = password ; BT OpenWorld service [Dialer btopenworld] ; BT are stupid. See the man page for details Stupid Mode = on Phone = 08089933001 Username = user@btopenworld.com Password = password I use a ISDN TA and have 2 ISP accounts I have also included a few useful sections. This allows me to use a modem if I need to or show information about the current device. You may want to include an option to turn the modem's speaker off. [root@router:~> # wvdial connectlite [root@router:~> # wvdial btopenworld modem info [root@router:~> # wvdial connectlite noreconnect Change wvdial to be used as a chat replacement ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Normally wvdial invokes pppd to negotiate the PPP connection after it has setup to the dial-up connection. We need pppd to invoke wvdial to setup the dial-up connection before it negotiates the PPP connection. Fortunately, wvdial has the ability to behave like the traditional way of using pppd, chap scripts. Unfortunately, when using wvdial normally, it passes various options to pppd on the command line, but as pppd is running wvdial, we can not do this. The solution is to put the options wvdial normally passes on the command line into an options file in /etc/ppp/peers. If you look in this directory, you should find a file called wvdial. Make a copy of this file ad call it something like dod. [root@router:~> # cd /etc/ppp/peers/ [root@router:/etc/ppp/peers> # ls provider wvdial wvdial-pipe [root@router:/etc/ppp/peers> # cp wvdial dod [root@router:/etc/ppp/peers> # ls dod provider wvdial wvdial-pipe We need to find out what options wvdial passes to pppd. We can do that by running wvdial and then looking at pppd's command line. We can grep the output of ps auxw [root@router:/etc/ppp/peers> # wvdial connectlite & [1] 1567 --> WvDial: Internet dialer version 1.53 router root% --> Initializing modem. --> Sending: ATZ OK --> Sending: AT &FE0x7 AT &FE0x7 OK --> Sending: AT B40 OK --> Sending: AT S84.4=1 OK --> Sending: AT S7=60 S50=0 L1 M1 &K3 &K44 &H3 OK --> Sending: AT S87.2=0 OK --> Modem initialized. --> Sending: ATDI08089933024 --> Waiting for carrier. CONNECT 64000/NONE/PPP --> Carrier detected. Starting PPP immediately. --> Starting pppd at Fri May 17 00:26:42 2002 --> pid of pppd: 1568 [root@router:/etc/ppp/peers> # ps auxw | grep pppd root 1568 0.0 0.1 2068 928 tts/0 S 00:26 0:00 \ /usr/sbin/pppd 115200 modem crtscts defaultroute usehostname -detach call wvdial user user@btconnect.com noipdefault idle 0 logfd 6 [root@router:/etc/ppp/peers> # killall wvdial Caught signal #15! Attempting to exit gracefully... --> Disconnecting at Fri May 17 00:27:23 2002 We need to put all the command line arguments in the /etc/ppp/peers/dod file. We do not need to put the '-detach' or the 'call wvdial' section in the file. '-detach' prevents pppd from going into the background and we probably want pppd to go into the background. The call wvdial section reads options from the '/etc/ppp/peers/wvdial' file, but as we copied the file we already have all the options that file contains. We also need to add an option so that pppd knows to call wvdial. Add the following line, changing the target for wvdial. connect "/usr/bin/wvdial --chat connectlite" We should now have a file that looks something like: noauth name wvdial connect "/usr/bin/wvdial --chat connectlite" /dev/ttyS0 115200 modem crtscts defaultroute usehostname user user@btconnect.com noipdefault idle 0 logfd 6 You can now check that you can still dial up using: [root@router:/etc/ppp/peers> # pppd call dod or [root@router:/etc/ppp/peers> # pon dod where dod is the name of the file in '/etc/ppp/peers'. You can stop the connection using poff. Edit the peers file to run with dial-on-demand ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We now have pppd bringing up the link when we run 'pon' and tearing down the link when we run 'poff'. We now have to make a few changes to the '/etc/ppp/peers/dod' file to make the link dial-on-demand. The first change is to tell pppd to start and create the interface, but only dial up when we first need to send a packet over that interface. To do this we add the demand option the the file. We now have a link that dials on demand, but we still have the link on permanently after it first dials. The solution is to get pppd to stop the connection after an idle period, i.e. no packets have left the interface for a number of seconds. We need to add the idle option to the file. This option requires a argument specifying the number of seconds of idle before tearing down the link. If you specify 0, the link will stay up permanently. You will probably find that wvdial used idle 0 and that therefore already have an idle option in the file. Just change the value to a suitable value. 300 will wait 5 minutes. You may want to use a shorter timeout, especially if you have expensive phone bills. The final problem is that normally, once pppd has closed the link, it exits. This means that once the link has come up and down once, the link will not work until someone runs 'pon' again. Fortunately, pppd has the persist option which prevents pppd form exiting after closing the connection. We should finally end up with a '/etc/ppp/peers/dod' file similar to: noauth name wvdial connect "/usr/bin/wvdial --chat connectlite" /dev/ttyS0 115200 modem crtscts defaultroute usehostname user user@btconnect.com noipdefault idle 300 persist demand logfd 6 You should now find that the link will be dial-on-demand and can be started by running 'pon dod' and stopped by 'poff'. You could put those in a crontab to start the dial-on-demand link in the morning and turn it off in the evening, so that you don't waste money by the link dialling due to an Internet application (like IRC) being accidentally left open.