You should be root to perform these checks since networking affects the whole system, many commands require root privileges.
If you are unsure of what any of these values should be, compare the output of the below commands with the same commands when using DHCP, or ask your Network Administrator.
IP Address and Netmask
Use the command `ifconfig eth0` to ensure you have a valid and correct IP address + Netmask combination. Replace 'eth0' with the appropriate interface for your machine, though it is usually 'eth0'.
The line of interest is the second line, starting with 'inet addr:'. In the above example, our IP Address is '192.168.1.101' and our subnet mask is '255.255.255.0'. Both of these examples are commonly used values.
Ensure you have a default route set; this tells the kernel where to send packets for hosts other than the local network. A default gateway is your Cable or DSL modem.
The last line with both 'Destination' and 'Genmask' set to '0.0.0.0' is the default gateway. In the above example, our default gateway is '192.168.1.1'
DNS servers are what converts domain names into IP Addresses. If you are able to ping IP Addresses outside your network, but not open websites etc then it is likely you have missing or invalid DNS servers configured.
- The 'nameserver' line is the relevant part of this file.
- You may or may not have the 'domain' line.
- There may be additional lines, and/or multiple 'nameserver' lines.
- It is common for your 'nameserver' to be the same as your default gateway (see above).
- If you are unsure, you can usually use Google DNS as your DNS Servers:
nameserver 184.108.40.206 nameserver 220.127.116.11
Test to ensure you can connect "out" one-step at a time. Start by pinging your default gateway. Replace '192.168.1.1' with your default gateway (as shown in `route -rn` from above:
# ping -c4 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=0.193 ms 64 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=0.190 ms 64 bytes from 192.168.1.1: icmp_req=3 ttl=64 time=0.192 ms 64 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=0.189 ms --- 192.168.1.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 2999ms rtt min/avg/max/mdev = 0.165/0.184/0.193/0.014 ms
The output above is considered successful; each line starts with "64 bytes from <ip address>". If you instead get errors stating "Destination Host Unreachable" then check and ensure that your IP Address/Netmask and Default Route are all correct.
Ensure this test SUCCEEDS before moving on to further tests!
Next, test if your router is passing traffic to the outside world correctly. Test by pinging a public address by IP Address. Google's DNS servers are good for this test since they respond to ping requests and are easy to remember:
# ping -c4 18.104.22.168 PING 22.214.171.124 (126.96.36.199) 56(84) bytes of data. 64 bytes from 188.8.131.52: icmp_req=1 ttl=51 time=171 ms 64 bytes from 184.108.40.206: icmp_req=2 ttl=51 time=170 ms 64 bytes from 220.127.116.11: icmp_req=3 ttl=51 time=170 ms 64 bytes from 18.104.22.168: icmp_req=4 ttl=51 time=170 ms --- 22.214.171.124 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3003ms rtt min/avg/max/mdev = 170.290/170.915/171.579/0.461 ms
Again, the above output is considered successful. If this test fails then it is likely that your PC is configured successfully, but your internet connection is disconnected for some reason.
Test DNS Servers
Check your current DNS servers in /etc/resolv.conf then test them, starting with the first.
Using the `dig` command, send a directed DNS query (using the '@' prefix to tell `dig` which server to ask) to your DNS servers for a DNS record. In this example, our DNS server is '192.168.1.1' and we are asking it for 'archlinux.org'
The important parts to this output are highlighted in bold below, and listed here:
- The "HEADER" line that states the 'status' is 'NOERROR'
- The "flags" line that shows we got 1 'ANSWER'
- It may also be relevant to ensure the 'ANSWER SECTION' provides the correct IP Address (for archlinux.org this is currently 126.96.36.199)
- If you are having performance issues, check the "Query time" value near the bottom. If this is more than ~500ms then there is a network performance issue somewhere that requires further investigation beyond the scope of this wiki article.
# dig @192.168.1.1 archlinux.org ; <<>> DiG 9.8.0 <<>> @192.168.1.1 archlinux.org ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14697 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4 ;; QUESTION SECTION: ;archlinux.org. IN A ;; ANSWER SECTION: archlinux.org. 7200 IN A 188.8.131.52 ;; AUTHORITY SECTION: archlinux.org. 61676 IN NS ns4.everydns.net. archlinux.org. 61676 IN NS ns1.everydns.net. archlinux.org. 61676 IN NS ns2.everydns.net. archlinux.org. 61676 IN NS ns3.everydns.net. ;; ADDITIONAL SECTION: ns1.everydns.net. 61675 IN A 184.108.40.206 ns2.everydns.net. 61675 IN A 220.127.116.11 ns3.everydns.net. 61675 IN A 18.104.22.168 ns4.everydns.net. 61675 IN A 22.214.171.124 ;; Query time: 264 msec ;; SERVER: 192.168.1.1#53(192.168.1.1) ;; WHEN: Fri May 20 15:45:17 2011 ;; MSG SIZE rcvd: 195