Accessing Internet with Linux

I would like to know how to access the internet through Linux.
Who is Participating?
sime788Connect With a Mentor Commented:
You need....

At least a 1.2 or 2.0 kernel with PPP support enabled.

If you're not sure, type cat /proc/version on the command line.

This should report the version you're running as something like:Linux version 2.0.29 ( version 2.7.2) #1 Sun Jan 26 13:11:05 GMT 1997

The pppd program You need version 2.1.2 for a 1.2 kernel, and 2.2.0 for a 2.0 and above kernel. You can check the version of pppd by typing /usr/sbin/ pppd -v on the command line. pppd will report its version and exit.

If you are unsure if your pppd is working or not, type /usr/sbin/pppd on your command line and press enter, you should get something like this:

[root@mybox sbin]# /usr/sbin/pppd

òò~ÿ}#À!}!}!} }2}!}$}%Ü}%}&Lç}4X}'}"}(}"_1~~ÿ}#À!}!}!} }2}!}$}%Ü}%}&Lç}4X}'}"}(

In the unlikely event that you don't have both of the above, you will need to get and install them. That's beyond the scope of this - see the PPP-Howto for more information.

Check to see that the directory /etc/ ppp exists; if not, create it by typing:

mkdir /etc/ppp as root. This is where your PPP configuration files will be placed.

Setting up DNS
Put the following in /etc/resolv.conf:

nameserver <your isp's primary>
nameserver <your isp's secondary>

The Chat Script

This is the script which pppd will use to negotiate the initial modem connection. Put the following in /etc/ppp/chatscript:

"" ATZ
OK ATDTXXXXXXX <- isp tel no
ogin: ""
ogin: uk,ppp,(username)
ssword: (password)
You must of course set up correct values for username and password above.

The ATZ init string works well for USR modems and some of the Rockwell modems

Note: this file should be owned by root and should not be world-readable; it contains your dialup password, which should be kept secret, especially if more than one person uses your Linux box.

chown root chatscript

chgrp root chatscript

chmod 440 chatscript

The pppd Configuration File
This file contains run-time configuration directives for pppd, have a look at the manual pages for pppd (man pppd). Put the following in /etc/ppp/options

If the file options isn't present create one using your favorite method (vi, pico, emacs, cat, touch, etc)

asyncmap 0 #Sets the async character map
crtscts    #set the modem to hardware flow control
kdebug 7   #for debugging purposes.
The ppp-on Script
This is the shell script you run to bring your connection up.

Put the following in /usr/sbin/ppp-on:

#  ppp-on - Set up a PPP link
# Change this to suit
# cua0 = COM1, cua1 = COM2, cua2 = COM3, cua3 = COM4
# use this dummy IP address for dynamic IP
if [ -f $LOCKDIR/LCK..$DEVICE ]; then
    echo "PPP device is locked"
    exit 1
/usr/sbin/pppd -d /dev/$DEVICE 115200 \
  connect "/usr/sbin/chat -v -f $CFG_DIR/chatscript" \
  defaultroute $MYIP: && exit 0
echo "PPP call failed"
exit 1
Note: this file should be owned by root.

chown root ppp-on

chgrp root ppp-on

chmod 755 ppp-on

The value for DEVICE should be cua0 if your modem is on COM1, cua1 if your modem is on COM2, and so on.

The ppp-off Script
This is the shell script you run to take your connection down.

Put the following in /usr/sbin/ppp-off:

#  ppp-off - Take down a PPP link
if [ "$1" = "" ]; then
if [ -r /var/run/$ ]
    kill -INT `cat /var/run/$`
    if [ ! "$?" = "0" ]; then
        rm -f /var/run/$
        echo "ERROR: Removed stale pid file"
        exit 1
    echo "PPP link to $DEVICE terminated."
    exit 0
echo "ERROR: PPP link is not active on $DEVICE"
exit 1
Note: this file should be owned by root.

chown root ppp-off

chgrp root ppp-off

chmod 755 ppp-off

Trying it out
You should now be ready to make a connection to your ISP. As root, type:

You should hear your modem dial and establish a Internet connection. Try pinging your ISP's DNS server, from the command line type: ping XXX.XXX.XXX.XXX and press return. After few seconds press Ctrl-C

All output from pppd is logged to the messages file; the first time you try to connect, you should watch this file for possible problems. To do this, type:

tail -f /var/log/messages
Press Ctrl-C when you're done. If all goes well, you'll see something similar to the following:

To check the status of the PPP interface, type:

ifconfig ppp0
The output should be similar to the following. If the command generated no output, the link is not up.

ppp0      Link encap:Point-Point Protocol
          inet addr:XXX.XXX.XXX.XXX  P-t-P:XXX.XXX.XXX.XXX  Mask:
          UP POINTOPOINT RUNNING  MTU:1500  Metric:1
          RX packets:5513 errors:0 dropped:0 overruns:0
          TX packets:6351 errors:0 dropped:0 overruns:0

To bring your Internet connection down, type /usr/sbin/ppp-off and the modem should disconnect.

At this point you're all set - happy browsing!

I get the error message 'Permissions denied'
Check the file permissions:
[root@mybox root]# ls -al /usr/sbin/ppp-on
-rwxr-xr-x 1 root root 203 Mar 21 19:20 /usr/sbin/ppp-onn

I get the error message 'Sorry - this system lacks PPP support'
This can be one of two things:
Your kernel does not the PPP drivers built in. You will need to compile a new kernel which does.
Make sure that you're using the correct serial device in the ppp-on script. Mistakenly selecting, say, the mouse as your serial device will result in this error - not very intuitive, but that's life :-)

Other Sources of Information
This is the main index for the Linux HOWTOs, there are some interesting documents over there.
You should definitely read the PPP-Howto. This is available from a number of places:

It is periodically posted to comp.os.linux.answers;
You may well have a copy locally, in /usr/doc/HOWTO;
Check out irqtune - a program to optimise your PC's interrupt priorities. Raising the priority of your serial interrupt can lead to a noticeable performance improvement.
Check out the Diald Home Page for information on setting up dial-on-demand networking.

A wealth of general information about Linux is available at and An extensive list of Linux software, including Internet applications, can be found at the Linux Applications and Utilities Page.
On the UnixWorld Online home page, there are various tutorials for the advanced Linux users.

The Mgetty software is a great fax package and can allow your Linux box to receive ppp connections and authenticate users.
There is a limitation of how many modems you can connect to your Linux box, a good idea is to get a multi serial card, there are various companies that supply those cards, Premier Electronics, has a wide range of multi serial cards.

A good browser to use with Linux is Netscape communicator 4.04, you can download from Sunsite

How? Via ppp dialup, cable modem, DSL service, or local LAN w/Internet access?
We need more info.

Do you mean dialing/connecting into your ISP, or once you are on, how do you surf?
Go Here and.....

Buy this...

"Linux the complete reference"

All Courses

From novice to tech pro — start learning today.