A 10-Minute Guide for Using PPP to Connect Linux to the Internet
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., 188.8.131.52.
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 184.108.40.206 then your /etc/resolv.conf file should have a line that says:
To start the PPP link, all you need to do is execute the following command as root:
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:
pppd reads /etc/ppp/options.
pppd executes /etc/ppp/net-connect.
chat reads data from /etc/ppp/net-chat.
pppd obtains IP address details from server.
pppd creates ppp0 device and configures it.
pppd creates default route.
pppd runs in background.
To test the connection, do each of the following steps in turn.
The ifconfig program is used to set or display network interface configurations. Here you are interested in displaying only.
The output should look like 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.
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 220.127.116.11
Output will be similar to what you observed when you pinged the PPP server.
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 0.0.0.0 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.fiIf 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.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Ubuntu Online Summit
- Devuan Beta Release
- The Qt Company's Qt Start-Up
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- May 2016 Issue of Linux Journal
- The US Government and Open-Source Software
- The Death of RoboVM
- Open-Source Project Secretly Funded by CIA
- New Container Image Standard Promises More Portable Apps
- BitTorrent Inc.'s Sync
In modern computer systems, privacy and security are mandatory. However, connections from the outside over public networks automatically imply risks. One easily available solution to avoid eavesdroppers’ attempts is SSH. But, its wide adoption during the past 21 years has made it a target for attackers, so hardening your system properly is a must.
Additionally, in highly regulated markets, you must comply with specific operational requirements, proving that you conform to standards and even that you have included new mandatory authentication methods, such as two-factor authentication. In this ebook, I discuss SSH and how to configure and manage it to guarantee that your network is safe, your data is secure and that you comply with relevant regulations.Get the Guide