Troubleshooting Network Connections

Home Computers Writings Trips

This troubleshooting guide is designed to assist the novice Linux user in troubleshooting the inevitable network problems that arise.  Although the troubleshooting steps are the same in all operating systems, the commands are  specific to Linux.  This guide assumes a basic level of networking knowledge, namely that the reader is familiar with terms IP address, subnet, gateway, and nameserver.  If not, brief definitions are given below:

IP address
Combination of four numbers from 0 - 255 (e.g. 192.168.0.1).
subnet
The first three numbers of an IP address
gateway
Sends packets from the local subnet to the wider world
nameserver
Translates www.google.com to 64.244.161.99

Contents

I.   Network Troubleshooting Guide
II.  Configuring the Network
III. Manually configuration your IP address (DHCP)
IV. Manually configuring your IP address (static IP)
V.  Manually configuring your nameserver
VI. Additional information

I.  Network Troubleshooting in Linux Taxonomy

Symptoms:

Cannot connect to site on the Internet
Goto 1
Cannot connect to a computer on the local network
Goto 1 (but use local servers or computers)
Cannot connect even by IP address
Goto 7

  1. Try two or three different well-known sites (e.g. Google, CNN, NYTimes, Slashdot).
    Fails:  Goto 2
    Works:  That particular site is down.

  2. Try connecting via an IP address (obtain by pinging from a working computer).  Note that many hosts drop ping packets, so you may get no response from a ping even if the server is up.  (Google and Slashdot both allow pings, as of this writing).  As of this writing (January 2005) some IP addresses are:
    www.google.com
    http://64.233.161.99/
    www.cnn.com
    http://64.236.24.12/
    www.nytimes.com
    http://199.239.136.24/
    slashdot.org
    http://66.35.250.151/

    Fails:  Goto 5
    Works:  You have a problem with your nameserver.  Goto 3

  3. Do `cat /etc/resolv.conf`.  You should have a line like "nameserver www.xxx.yyy.zzz".
    This line exists: Goto 4
    This line does not exist: 
    If you are using a static IP address, you need to setup your nameserver configuration.  If you are using DHCP goto 11.

  4. Ping your nameserver.
    Fails:  Your nameserver is down.
    Works:  You have the wrong nameserver.  Contact your system administrator or ISP for the correct nameserver.

  5. Ping your gateway.  If you don't know your gateway's IP address, do `route` (or `/sbin/route` if it isn't in your path).  You should see something like the following (the gateway's IP address is bolded):
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
    loopback        localhost       255.0.0.0       UG    0      0        0 lo
    default         192.168.1.1     0.0.0.0         UG    1      0        0 eth0

    No gateway:
    Your network settings are incomplete.
    Fails:  Goto 6.
    Works:  The connection to your ISP is down, your gateway is not forwarding packets properly, or you have the wrong gateway.

  6. Ping another computer on the network.  You can determine its IP address with `ifconfig` (Unix), `ipconfig` (Windows NT/2000/XP), `winipcfg` (Windows 95/98/ME).
    Fails:  Goto 7.
    Works:  Your gateway is down or you have the wrong gateway.

  7. Determine your IP address with `ifconfig`.
    No IP address:   Ethernet has not been configured.
    Address is 127.0.0.1:  Goto 8.  The network configuration init script either did not run or failed, or your drivers weren't loaded (or are incorrect).
    The first three numbers are not the same as your other computer:  Your computer IP address is incorrect.  (Example:  your IP address is 192.168.1.50 and the other computer is 192.168.2.13)

  8. Configure your IP address by hand:  `ifconfig eth0 netmask 255.255.255.0 address xxx.yyy.zzz.50` where xxx.yyy is your local subnet.
    Fails:  The drivers for your ethernet card aren't loaded.  Check /etc/modules.conf and the output of `dmesg`.
    Works:  Goto 9

  9. Ping the other computer on the network again.
    Fails:  Your network cable is bad or unconnected.  Try again with a known good cable.  (If you made your own cable, you can't just pick any wires.  This works fine for 10baseT, but things have a tendency to assume 100baseT without verifying that the cable supports this, manifesting itself with a link light but no data transfer.  For 100baseT you must use either the T568A or T568B standards or the high frequencies will induce crosstalk that will render the cable useless.  See this wiring diagram.
    Works:  Goto 10

  10. Are you using DHCP or static IP addresses?  (If you don't know the answer to this, you are probably using DHCP)
    DHCP:  Goto 11
    Static IP:  Your network script didn't work right or didn't run.  Look in your init scripts (usually /etc/init.d/rcn.d, where n is probably 5) to try to figure out why.

  11. Make sure dhcpcd is installed.  (`which dhcpcd`, `man dhcpcd`, `rpm -q -a | grep dhcpcd`, etc.)  Now do `dhcpcd -d eth0`.
    No response:  You successfully got an address from your DHCP server.  Thus your network script didn't work right or didn't run.  Look in your init scripts (usually /etc/init.d/rcn.d, where n is probably 5) to try to figure out why.
    Failed:  Your DHCP server is down or your network does not have a DHCP server.  Check /var/log/messages for debugging output from dhcpcd;  although it is not usually helpful, it is better than nothing.  You will probably see DHCP_DISCOVER packets being sent and nothing being received, which means that a DHCP server is not responding to the requests (presumably because it either doesn't exist or isn't working).

II.  Configuring your network

Most distributions have a user-friendly way of configuring the network;  this is the best way.  All distributions can be edited manually, but some distributions (like RedHat) store the information in multiple files which can be hard to find.  The best ways for a number of popular distributions are listed below:

RedHat
system-config-network-druid or netconfig
SuSE
yast2
Mandrake 
drakenet
Debian
dpkg-reconfigure etherconf
Gentoo
None.  Edit /etc/conf.d/net and /etc/resolv.conf

III.  Manually configuring your IP address (DHCP)

DHCP should be used when possible, as this will be easiest.  It requires either dhcpcd or pump, preferably the former.  Execute the following (as root):

    dhcpcd:
      ifconfig eth0 down
      dhcpcd -h hostname -d eth0

    pump:
      ifconfig eth0 down
      pump -i eth0 -h hostname

Run `ifconfig eth0` and check the IP address.  If it is not good, then you were unable to communicate with the DHCP server;  check your network cable, hub/switch, and the DHCP server.  If you are using dhcpcd and used the -d option, check /var/log/messages for more information.

This method should only be used for testing;  please use the method described in II for a long-term solution.

IV.  Manually configuring your IP address (Static IP)

Static IP addresses are more reliable because there is no server involved, but less flexible.  The commands are also more complicated to remember.  You will need to know your gateway's IP address (usually 192.168.1.1) and you will need an IP address that nobody else on the network is using.  Most home network routers (e.g. LinkSys) use .100 and above for dynamic allocation, so you probably want to pick one less than that, but relatively high, since most people will pick a low number.  The commands below assume that you picked 192.168.1.50.  Also, some home networks use a different subnet than .1.* (e.g. 192.168.2.*), so be sure to check the details of your network.

      ifconfig eth0 down
      ifconfig eth0 netmask 255.255.255.0 address 192.168.1.50
      route add gw 192.168.1.1
      edit /etc/resolv.conf to contain:  nameserver 192.168.1.1 (or the correct nameserver)

Note that you need to the route command or you will be stuck within the local network, unable to get to the Internet to solve your problem.  You also need to edit /etc/resolv.conf so that you can use www.google.com instead of their IP address, which you probably don't know.  (DHCP automatically replaces /etc/resolv.conf, which is why it wasn't mentioned above.)

This method should only be used for testing;  please use the method described in II for a long-term solution.

V.  Manually configuring your nameserver

Name resolution settings are set in /etc/resolv.conf.  The format is

      domain domain.name
      nameserver www.xxx.yyy.zzz
      ...

The domain listed is what will be used if nothing is appended to a hostname.  For instance, if you specified "domain google.com", then `ping www` would translate to `ping www.google.com`.  Multiple nameservers may be listed in case some of them are not working.  DHCP uses this file, too, but it is not necessary to specify it by hand as the DHCP client will overwrite it (restoring it when the client exits).

VI.  Additional information



Copyright © 2005 by Geoffrey Prewett