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    192.168.0.254    0.0.0.0     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 www.amazon.com 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
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0
OK
--> 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 www.z.com you don't need to go further. Have a nice surfer)
ifconfig ppp0

ppp0 Link encap:Point-to-Point Protocol
inet addr:174.255.252.184 P-t-P:174.255.252.248
Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:225 errors:0 dropped:0 overruns:0 frame:0

OK, we get an public address from the ISP, 174.255.252.184

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
174.255.252.184 * 255.255.255.255 UH 0 0 0 ppp0
192.168.0.100 * 255.255.255.255 UH 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 192.168.0.1 0.0.0.0 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 174.255.252.184).

Please enter:
route add -net 0.0.0.0 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 174.255.252.184.

Let recheck the route
netstat -nr

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use
174.255.252.184 * 255.255.255.255 UH 0 0 0 ppp0
192.168.0.100 * 255.255.255.255 UH 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
default 174.255.252.184 0.0.0.0 UG 0 0 0 ppp0

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

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:
#!/bin/bash
route add -net 0.0.0.0 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