Dial-up - Configuring Linux for Dial on Demand

Summary: Linux Connection Guide

Our 0845 and 0808 dial-up products were withdrawn from service in January 2015. To find out more about this, or if you have any questions please see our Dial-up closure FAQ.

This guide explains how to configure your Linux server or workstation to dial the Internet on demand.

Modem compatibility

Many websites are available to help you find out if your modem is compatible with Linux. Check the following :

Modem type and compatibility with Linux
Modem setup strings
Simple firewall package


There are two main packages - pppd [to get online using ppp] and ipchains [to 'firewall' your connection]. Two of the many optional packages are crond [to schedule when your connection is available] and minicom [to test your modem]


You will need to be the 'root' user to follow these instructions. Please note - these instructions apply in general to using a 'real' modem, (e.g. a modem which doesn't need a software driver to run as many winmodems).

1 . Connecting the modem
The communications ports in Linux are named differently to those in Windows. The correct communications port to use is the one with devices listed in the /dev directory which begin 'ttyS'.

Examples are: /dev/ttyS0, /dev/ttyS1, /dev/ttyS2 and /dev/ttyS3 for Com ports 1 to 4 respectively.

In this example the modem is connected to Com2. You may also want to make sure that your com port is operating at an appropriate speed. You can use the setserial command to check and change the settings for the com port.

[root@ashaman]# setserial -g /dev/ttyS1
/dev/ttyS1, UART: 16550A, Port: 0x03f8, IRQ: 4

Most distributions provide a rc.serial or serial script in the init directories. These set the com port flags at boot time for each com port. If you cannot locate these, or have reasons for setting com speeds differently then you might create the following shell script, not forgetting to chmod +x the script before running it.

setserial /dev/ttyS0 uart 16550A port 0x03f8 irq 4 baud_base 115200 spd_vhi skip_test

If you ran the above your com port may look like.

[root@ashaman bin]# setserial -g /dev/ttyS0
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4, Flags: spd_vhi

2. Ensuring your requests for the Internet are responded to
[root@ashaman nik]# cat /proc/sys/net/ipv4/ip_forward 1

If you see 0 here then you can set this value tru by typing:

[root@ashaman nik]echo 1 >/proc/sys/net/ipv4/ip_forward

You may want to make sure that this value is set every time that the ppp connection is requested. Later in this guide we give an example of how to place this in a shell script before starting pppd.

3. Making sure your machine is secure
To create a firewall and protect your machine from unwanted access you should use an ipchains rule set to control access and stop unwanted visitors. Simply download the ipchains files, unpack them and place the file firewall.sh in /usr/sbin making sure the file firewall.sh is executable. You can enable the firewall by specifying the name of the external ppp device, usually zero and in the internal networking device.

[root@ashaman]firewall.sh ppp0 eth0

Note eth0 is necessary where you are using Linux as a gateway between the Internet and a local area network, otherwise the following command will protect your machine.

[root@ashaman]firewall.sh ppp0

4. Resolving names on the Internet
You will need to let Linux know how and where to locate Internet sites. This guide assumes that you are not using Domain Name Server local to your box. You will need to amend at least 2 files. By default your Linux distribution will have configured the other host files correctly.

order hosts,bind
multi on

5. Configuring PPP
Distributions of Linux vary, but in general the configuration files for PPP will be stored in /etc/ppp . In the example a simple ppp options file will be created along with a chat script (which will dial the modem). PPP connections will vary depending on the service you are dialing. You will need to amend the chat script accordingly and this is shown below. PPP Connections come in two parts: the chat script and the pppd options.

5.1 Chat Script

To dial-up on a Connect account.

exec chat -s -v \
SAY "Set modem responses" \
ABORT '\nBUSY\r' \
ABORT '\n% Authentication failed\r' \
'' \rAT \
'OK-+++\c-OK' ATH0 \
SAY "Send number " \
SAY "Set modem Reponses" \
OK "ATX4V1Q0S7=70" \
OK "ATM0L0DT0808,9933,0xx" \
SAY "Wait for connect" \

Note: replace xx with the appropriate number for the dial-up service you are using.

To dial-up via 0845

exec chat -s -v \
SAY "Set modem Reponses" \
ABORT '\nBUSY\r' \
'' \rAT \
'OK-+++\c-OK' ATH0 \
SAY "Send number " \
SAY "Set modem Reponses" \
OK "AT&F" \
OK "ATM0L0DT0845xxxxxx" \
SAY "Wait for connect" \
Login:--Login: [your username here] \
Password: [you password here]

NB: replace xxxxxx with the appropriate number for your account type.

If you want to configure your modem more accurately then make sure that you surround the AT command with quotes. Read how to do this. Remember to set the scripts as executable e.g. chmod +x dial0845sh

5.2 PPP Options
Options file for dial-up on a Connect account.

name [your username here]
connect-delay 2
asyncmap 0
maxfail 0
holdoff 1
connect /etc/ppp/connect.sh
idle 1800

Note: you need to use either connect.sh or dial0845.sh as the connection script. For more information about these options try man pppd.

5.3 Other Script options
[your username here] * [your password here]
firewall.sh ppp0

Remember to use firewall.sh ppp0 eth0 for a local area network.

5.4 To Launch ppp
[root@ashaman]/usr/sbin/pppd /dev/ttyS0 115200 noauth

From here ppp should become enabled once a request has been made to access the Internet. Once PPP is running it will automatically start the chat script to dial the modem and access the Internet . If you want to stop the pppd process you will need to locate its process ID and stop it. This can be done with the following command:

[root@ashaman] ps -ax | grep pppd
29064 ttyS1 S 0:00 pppd

The value 29064 is the process id of the running pppd application. You can also find this value by typing the following command:

[root@ashaman] cat /var/run/ppp0.pid 29064

In either situation you can stop the process by issuing the 'kill' command

[root@ashaman] kill 29064

Or you could type:

[root@ashaman] kill `cat /var/run/ppp0.pid`

6. Making life simpler
Some example scripts to automate stopping and starting ppp

ifconfig ppp0 down
echo 1 >/proc/sys/net/ipv4/ip_forward
pppd /dev/ttyS1 115200 noauth
echo "done."
for pppdevice in /var/run/ppp?.pid
if [ -f $pppdevice ]
kill `cat $pppdevice`

7. Automating the pppd process
You could add an entry to the cron deamon process that would call these scripts. In this example the pppd process is started at 6am each day and stopped at 11pm each day.

[root@ashaman] crontab -e

0 6 * * mon,tue,wed,thu,fri,sat,sun /root/bin/surf.sh
0 23 * * mon,tue,wed,thu,fri,sat,sun /root/bin/internet-down

This document was originally written by Nicholas Butler, Technical Director of Wired4Life

Did you find this page helpful?

Yes No Maybe