A 10-Minute Guide for Using PPP to Connect Linux to the Internet

Having trouble connecting to the Internet? Here's an easy way to do it using PPP.
Configuring the Name Resolver

The name resolver is a small piece of software within the standard Linux library that allows automatic conversion of a host name, e.g., sunsite.unc.edu, into an IP address, e.g.,

Configuration of the name resolver is easy; there is only one file to change. You will almost certainly already have this file on your machine, but you will need to configure the correct address for the nameserver. Assuming your ISP supplied you with a nameserver address of then your /etc/resolv.conf file should have a line that says:

Starting the Link

To start the PPP link, all you need to do is execute the following command as root:

# /usr/sbin/pppd

The pppd program will start and will search for its options in the standard locations. It will find our options file at /etc/ppp/options and read each line. When it has finished processing all available options, it will open the specified serial device, create a lock file to prevent other programs from trying to use it, and then attempt to run the connect program and to execute the /etc/ppp/net-connect script. The net-connect script will execute the chat program telling it that it should take its parameters from the /etc/ppp/net-chat file. The chat program starts, reads each of the lines from the net-chat file, waits for the strings, and sends the responses it has been given. Provided the chat program did not ABORT then control is passed back to the pppd program, which will then switch the line into PPP mode and create a PPP network device. The pppd program will automatically begin negotiation of some configuration details with the PPP program at the other end of the link. The most important of these details is the IP address you will use. The pppd program will create a ppp network device ppp0 and then configure it with the details it obtained from the other program. Finally, the pppd program will configure your routing table with a route that tells your Linux machine it should send datagrams to the PPP link, if it doesn't have anywhere better to send them. The pppd program will then sit happily in the background until either the line fails, the remote end closes the connection or you terminate it locally.

Okay, that sounds complicated, so a summary:

  1. pppd starts.

  2. pppd reads /etc/ppp/options.

  3. pppd executes /etc/ppp/net-connect.

  4. chat reads data from /etc/ppp/net-chat.

  5. pppd obtains IP address details from server.

  6. pppd creates ppp0 device and configures it.

  7. pppd creates default route.

  8. pppd runs in background.

Testing the Connection

To test the connection, do each of the following steps in turn.

Step 1:

run /sbin/ifconfig

The ifconfig program is used to set or display network interface configurations. Here you are interested in displaying only.

Step 2:

# /sbin/ifconfig

The output should look like Listing 1.

Listing 1

The inet addr field is the IP address you have been allocated. The P-t-P field is the address of the PPP machine at the other end of the link. This means your PPP network connection has been successfully established.

If you don't see a ppp0 device, check your system log file, i.e., /var/adm/messages, to ensure that your chat script worked successfully. Correct any possible errors. If you see any nasty looking error messages, double check that you are using the correct version of PPP for your kernel.

Step 3: ping the PPP Remote Host. The ping command sends specially formatted datagrams to a host that that host will send replies to. This allows us to check that we have a working route to that host. Listing 2 shows our case. Those “64 bytes from ...” lines in the listing mean we are talking successfully to the machine at the other end of the link. This is good, since it means the link is working.

Listing 2

If you don't see any of the “64 bytes from ...” lines, this means you are not properly talking to the remote machine. Double check your chat script and the system log file.

Step 4: ping your nameserver. This is an important test to be sure the default route pppd put in place is working. To do this, ping the nameserver address configured into the /etc/resolv.conf file. In our case:

# ping

Output will be similar to what you observed when you pinged the PPP server.

Listing 3

If this test fails, it could mean your default route hasn't been added properly. To double check, run the route command as shown in Listing 3. The route command displays the contents of the IP routing table. The -n option tells it not to try and convert IP addresses into host names. The line starting with is the default route. If you don't see a line like this, double check that you have included the defaultroute option in the /etc/ppp/options file. If you have a line like this but it doesn't point to ppp0, check that your system isn't already creating a default route to another device. If it is, find which rc file is doing it and comment out this entry.

Step 5: ping a remote host. This is the real and simple test. Try either:

# ping sunsite.unc.edu


# ftp ftp.funet.fi
If this works, you are connected properly to the Internet. Enjoy.

If the command just sits there and, after a minute or so, gives you an error message about being unable to resolve the host name, check that you have modified your /etc/resolv.conf file correctly, and that the IP address you have configured there is the correct IP address for your ISP's nameserver.



Comment viewing options

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

regarding GPRS modem connection and ppp link

Anonymous's picture

Dear Sir,

I am able to establish a ppp connection through modem but when i kiil the process then i am not able to reconnect .

I am havingppp-on entry in the inittab file aslo. all options are set correct. Modem doesnot process AT commands untill hard reseted i.e power downing the modem.

Any help & suggestions would be highly appreciated.


Free Dummies Books
Continuous Engineering


  • What continuous engineering is
  • How to continuously improve complex product designs
  • How to anticipate and respond to markets and clients
  • How to get the most out of your engineering resources

Get your free book now

Sponsored by IBM

Free Dummies Books
Service Virtualization

Learn to:

  • Define service virtualization
  • Select the most beneficial services to virtualize
  • Improve your traditional approach to testing
  • Deliver higher-quality software faster

Get your free book now

Sponsored by IBM