Howto easily install an internet connection with a modem?

Release 1.3 16th October 2002, suited for RH8 too

Assuming:The communication/interface between your modem and the operativ system must work 100%. You can check it with setserial /dev/ttyS0 (or ttyS1 for serial port 2; setserial shows the configuration (I/O, IRQ) for the serial port) and cat /bin/true >/dev/ttyS0 (or ttyS1; make sure that the RxD/TxD leds blink). For those who have problem (specially with the internal Winmodem) please stop and read the good explanation "Winmodems-and-Linux-HOWTO", the many-good-links in "Linmodem-HOWTO" and the basic "Modem-HOWTO".

Preface: At first I want to thank to Bill Staehle, he is the man behind the scene. Thanks to your suggestions and corrections for this documentation.

To access the internet over the phone line you need to use the Point to Point Protocol (PPP). It is very easy and fast to install and setup a modem connection to your Internet Servcie Provider (ISP) if you know how. We only need wvdial V1.41, wvdialconf and vi/mcedit, neither neat nor kppp. The last two applications are the tools from Redhat7.2/KDE.

What to do:
a) This step is NOT necessary, it is only for showing you the clarity of the simple PPP connection. Make sure there are no ifcfg-ppp0 interface (not mix up with ifcfg-eth0, it is for the network card) at /etc/sysconfig/networking/devices, /etc/sysconfig/networking/profiles/default and /etc/sysconfig/network-scripts. Delete or rename them. Yes, we do not use them, it is enough with the infos from wvdial.conf.

b) Rename the file /etc/wvdial.conf. Don't matter if you do not have one.

c) Make sure there is no pre-existing default route using some bogus IP address on your LAN (if you have one). Look at the output of the command 'netstat -nr' and see that there is NOT a route to the "default". Something like this one:

default     UG    0    0    0  eth0 

This line may/must not be there. If it is, remove the GATEWAY line in /etc/sysconfig/network or /etc/sysconfig/networking/devices/ifcfg-eth0 (NB: If you want to play with multiple default routes, you can left it there. The trouble is that you need to add a new default route manually, I will show you how to do it below).

The preparation is now ready, please follow the following steps:

1) Let the system updates the configuration file in /etc. If you have an external modem, please turn it on and execute the next command from the console.
wvdialconf create (NB!!: it will not works in RH8!! you need to type:wvdialconf /etc/wvdial.conf)
The application wvdialconf scans all the serial ports through and update some information in /etc/wvdial.conf.

2) Modify the file /etc/wvdial.conf with your own login informations. It may look something like:
[Dialer Defaults]
Modem = /dev/ttyS1
Baud = 115200
SetVolume = 2
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0
Remote = *
Phone = 14071983
Password = foryoureyeonly
Username = sony
Stupid Mode = 1

The Remote option is for the PAP/CHAP authentication (it is set by default, anyway).

3) Update the Domain Name Service's (DNS) IP-address (you get it from the ISP too) in /etc/resolv.conf. Add at the bottom of the file: "nameserver X.X.X.X" (without quotas; a good idea to have more than one DNS from the ISP in case if one of them is down), where X.X.X.X is the DNS. DNS are using to convert the regular name just like to an IP address, which then using by the TCP/IP protocol to send the packets to the destination.

4) Voila, we are now ready to call the ISP. Please enter:
wvdial (warning!! not work in Redhat8, please read on)

wvdial will use the default setting in wvdial.conf. When you run it the first time, it will update (it gets the Username/Passwd from /etc/wvdial.conf) your /etc/ppp/chap-secrets and pap-secrets (sh.. it not works in Redhat8, you need to update those two files manually, see below) for making authentication with your ISP. (For RH8 only: the two files chap-secrets & pap-secrets are identical, it looks something like:

# client    server    secret              IP addresses
 sony     *       foryoureyeonly
You are now ready for executing wvdial)
You will get something like:

--> WvDial: Internet dialer version 1.41 (or 1.53 for RH8)
--> Initializing modem.
--> Sending: ATZ
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0
--> Modem initialized.
--> Sending: ATDT 14071983
--> Waiting for carrier.
ATDT 14071983
CONNECT 115200
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Wed Aug 14 19:15:22 2002

5) Let check if everything is OK. (if you are able to ping, say you don't need to go further. Have a nice surfer)
ifconfig ppp0

ppp0 Link encap:Point-to-Point Protocol
inet addr: P-t-P:
RX packets:225 errors:0 dropped:0 overruns:0 frame:0

OK, we get an public address from the ISP,

6) Let check the route. We must have a gateway/route, it works like a relay, where we can "go through" it to the outside.
netstat -nr

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use * UH 0 0 0 ppp0 * UH 0 0 0 eth0 * U 0 0 0 eth0 * U 0 0 0 eth0 * U 0 0 0 lo
default UG 0 0 0 eth0

It seems NOT correct, there is one gateway missing! Look at the last line it is the GW for the whole network, but unfortunately that interface eth0 does NOT connect to the outside world, but the ppp0 interface. We add a GW with the interface ppp0. (the first line just tells us that the ppp0 interface has the IP-addr

Please enter:
route add -net gw X.X.X.X ppp0
, where X.X.X.X is the public IP binding to the interface ppp0, in this case it is

Let recheck the route
netstat -nr

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use * UH 0 0 0 ppp0 * UH 0 0 0 eth0 * U 0 0 0 eth0 * U 0 0 0 eth0 * U 0 0 0 lo
default UG 0 0 0 eth0
default UG 0 0 0 ppp0

It is better now. We are now able to ping anywhere through the ppp0 interface.

The step 5 and 6 are only necessary if your route table somehow not update correctly (e.g. if you play with multiple default routes like me).

If somehow you want to have more than one default route, instead of adding the route manually, you can do it from a script. Create a file called /etc/ppp/ip-up.local (with chmod 755) with the following 2 lines:
route add -net gw $4 $1

The parameters $4 and $1 are defined automagically by pppd, and the file "ip-up.local" will be automatically executed when you run wvdial.

Good luck and bon surfer-voyage.

Copenhagen August 2002, Tuan Nguyen