One of the first things people usually want to do with their new Linux system is access the internet through a modem.
I use ppp (Point-To-Point Protocol) instead of SLIP (which was a historical accident). 'ppp' is easier to setup and offers many more features than SLIP. To learn about alternate ways of setting up ppp read PPP Setup Tips or the Linux PPP-HOWTO.
Although there are several ways to setup a ppp modem connection, I'll describe a simple (manual) configuration method. The X Control Panel provides a graphical setup script, but I find the resulting configuration is too inflexible and difficult to customize because they make use of several obscure setup files in the /etc/sysconfig/network-scripts directory (ignoring the standard /etc/ppp files) which has caused me more trouble than its worth. I assume your ISP performs automatic PAP negotiation (some ancient servers don't), otherwise you will have to further research the nuances of the chat program
In order to setup ppp you will need to use a text editor such as vi or joe.
vi is installed by default, and is present on almost every *nix system. For help on using vi, run the vi program and enter :help
If you want to use an editor with Wordstar-syntax, try joe, but you will have to install the joe RPM first. For help on using joe read the manpage by typing the command man joe from a command-shell.
Before you start setting up ppp, make sure you have the following information:
What is the phone number of your ISP (Internet Service Provider).
What is the IP of your ISP's nameserver.
What is your userid and password on the ISP system.
First you must setup a softlink between your serial port and the modem device. On my A2000 this was done by typing the command:
ln -sv /dev/ttyS0 /dev/modem
You can verify the softlink, cables, and modem connection by running the minicom program. On startup minicom will attempt to initialize your modem. The last line displayed in the middle of the screen should be a simple "OK". Verify your modem is responding by typing (in upper-case without quotes) "ATZ" and press <return>. The modem should respond with OK.
You can verify your phone connection is working by manually dialing your ISP by typing "ATDT xxx" where xxx is the phone number of your ISP. The modem should make the call and your ISP should answer. If you get a successful connection you may see a login prompt or a bunch of garbage characters (ppp negotiation), which is different for each ISP. Hang up the modem by entering three plusses "+++", wait 2 seconds, then type the command "ATH0" (or "ATH", or simply turn off your external modem). You can now exit minicom by entering control-a (^a) followed by control-x (^x). Make sure you can perform these steps before you proceed any further.
cd
to the /etc/ppp directory and create a file called "options". Using a text editor enter the following lines making sure to replace <your userid> with your actual userid as expected by your ISP:
/dev/modem |
Notice that I specified a baud-rate of 57600. If your system/modem wont run this fast try a lower value such as 38400. Save this file and create another one called "dialout". Enter the following lines (of a chat script):
ABORT BUSY |
Make sure to replace my "522-0375" phone number with the actual phone number of your ISP. Save this file. For background on what this is really doing, read the chat manpage [ type man chat ]. Also consult your modems manual for any additional options you might want to send during the dialup.
Next, create a file called "pap-secrets" and enter the following, making sure to replace <user userid> <your password> with the your actual ISP account userid and password.
<your userid> * <your password> |
Save this file and exit the text editor.
One more issue must be dealt with- your default nameserver. This is specified in a file called "/etc/resolv.conf." Edit this file making sure to replace <your nameserver> with IP of the nameserver recommended by your ISP. Leave any other lines in this file alone.
nameserver <your nameserver> |
Now its time to test your PPP connection. One debug aid provided by ppp is that it sends some helpful information to the system logger. You can view this information on another VCON or xterm window by typing "tail -f /var/log/messages". Switch back to your first command shell and enter the command "pppd". The modem should start dialing and you can watch its progress by switching back to the VCON or xterm that is running the tail command you just started.
For your reference, here is a sample system-log of a successful ppp connection, ping command, and disconnect:
May 16 16:25:31 sidekick kernel: registered device ppp0 |
As a test your should try to ping a machine on the internet, such as your ISP, or some other nearby system.
To disconnect from your ISP, enter the command killall pppd.
For additional help, try reading the man pages for pppd and chat.
If you are an advanced Linux-er, the new ppp-2.3.3 supports automatic demand-dialing and disconnection after a defined period of inactivity. To use this you must upgrade your kernel to at least 2.0.33, download the new ppp package and install its kernel patches, then reconfigure and recompile your kernel. This version of ppp has one nasty bug: Once you start the PPP daemon your network will stop working until you establish a connection with your ISP. The network works fine after this, even if the modem hangs-up and reconnects. (this problem took a several days to diagnose).
Another advanced networking topic is IP-Masquerade, which allows your Linux machine to act as an internet gateway for your entire local network (yes, other machines on your home network can simultaneously access the internet through your single modem connection- I'm doing this right now as I sit here writing, testing and uploading this document on several systems). Check out the Masquerade Homepage for details.
Once you get masquerade going you will probably want to run a local nameserver so you don't have to wait for DNS lookups on every single internet access. Another optimization to look into is the SQUID html caching server, which can be used to block many of those annoying advertisements found on commercial web pages.