Configuring pppd in Linux, Part II

After showing you how to configure your modem in Part I, Tony moves on to show you how to connect to the Internet.
Testing the Connection

The next step is to test whether the connection actually works. The best way to see if the link is up is to run ifconfig (see Listing 1). This command shows you the active kernel network interfaces. In my case, I have lo, the standard loopback interface I will use if I want to connect to myself, and ppp0, which is the modem PPP interface.

Listing 1. The Result of My ifconfig Command

To see if you actually are routing to the Internet, you can run the traceroute command, followed by any IP address. For now you should use the -n option in order to disable the DNS name resolution (that hasn't been configured yet). For example:

traceroute -n 198.182.196.56
traceroute to 198.182.196.56 (198.182.196.56),
30 hops max, 38 byte packets
 1  194.232.195.4 (194.232.195.4) 181.518 ms
    139.473 ms  149.822 ms
 2  194.232.195.1 (194.232.195.1) 129.540 ms
    139.739 ms  139.821 ms

...

19  207.245.34.122 (207.245.34.122)  479.696 ms
    479.653 ms *
20  198.182.196.56 (198.182.196.56) 489.711 ms
    479.644 ms  479.874 ms
The IP 198.182.196.56 is the server for www.linux.org. The program traceroute will tell you about the path followed by the packets you send to the Internet. Now, you should make sure that you tell your system the IP of your DNS, through the file /etc/resolv.conf. My resolv.conf file looks like this:
nameserver 203.14.168.3
nameserver 202.0.185.226
Some ISPs don't provide a DNS server address, as your computer is given one once the PPP handshake is completed. If that is the case, you simply can disconnect and reconnect using the usepeerdns option when you run pppd:
pppd /dev/modem 38400 modem lock
connect /etc/ppp/chat-connect
user your_username_here defaultroute usepeerdns
Now, you can try to see if your DNS is working, using, for example, the Telnet program. The Telnet program is only an excuse to see if the system was able to translate the name www.linux.org into an IP address.
telnet www.linux.org 80
Trying 198.182.196.56...
Connected to www.linux.org.
Escape character is '^]'.
It worked! Now, you can start your browser (Netscape, Mozilla, Opera, Galeon, Lynx, etc.) and browse the Net as you like.

A Bit of Housekeeping

By now, everything should work well; the internet connection is up, and you can connect to the Internet whenever you want. There is, of course, room for improvement. The first thing to do would be to increase the speed of the serial port and see if everything still works. To do that, just substitute 38400 with 115200 in the pppd command line.

Also, after a couple of weeks you probably will start noticing that there is a high number of parameters that have to be typed for the command pppd. In fact, every time you want to connect you have to type:

pppd /dev/modem 115200 modem lock
connect /etc/ppp/chat-connect
user your_username_here defaultroute

The good news is that you can, of course, put all those parameters in a configuration file, /etc/ppp/options. So, in your case, the options file would look like this:

/dev/modem
115200
modem
lock
connect /etc/ppp/chat-connect
user
defaultroute
In this file the order of the parameters really doesn't matter. From this point on, you will be able to connect to the Internet simply by typing the command pppd. What happens if you have several providers you might want to call? In this case, you can create several options files and then place them in /etc/ppp/peers. The output below shows what my peers directory looks like:
ls -l /etc/ppp/peers
total 4
-rw-r--r--  1 root   root    197 Aug  4 15:41 main_net
-rw-r--r--  1 root   root    189 Mar 11  2000 primus
My file /etc/ppp/options is empty; when I run pppd, I always run:
pppd call main_net
This way, the file /etc/ppp/peers/main_net will be used as well as my /etc/ppp/options file (which happens to be empty). If my main provider (Main Net) is down for some reason, I still can use some of my time-limited account with Primus.

Now, the best thing you can do is to read the man page for pppd (just type man pppd) and see if any of the esoteric options can somehow improve your connection. In Listing 2 you will find a very rich options file written by my friend and Linux guru Pancrazio De Mauro. Can you do better than that?

Listing 2. Pancrazio's Options File

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Take Command: Configuring pppd in Linux, Part II

Anonymous's picture

Really helpful

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState