Difference between revisions of "Network Debugging"

From ArchWiki
Jump to: navigation, search
(Fixed heading levels)
m (IP Address and Netmask)
Line 13: Line 13:
 
{{Cli|# ifconfig eth0<br>eth0      Link encap:Ethernet  HWaddr 00:9A:34:B7:45:FE<br>          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0<br>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br>          RX packets:9720423 errors:0 dropped:0 overruns:0 frame:0<br>          TX packets:7373481 errors:0 dropped:0 overruns:0 carrier:0<br>          collisions:0 txqueuelen:1000 <br>          RX bytes:6280519397 (5989.5 Mb)  TX bytes:835693640 (796.9 Mb)<br>          Interrupt:28 Base address:0x4000}}
 
{{Cli|# ifconfig eth0<br>eth0      Link encap:Ethernet  HWaddr 00:9A:34:B7:45:FE<br>          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0<br>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br>          RX packets:9720423 errors:0 dropped:0 overruns:0 frame:0<br>          TX packets:7373481 errors:0 dropped:0 overruns:0 carrier:0<br>          collisions:0 txqueuelen:1000 <br>          RX bytes:6280519397 (5989.5 Mb)  TX bytes:835693640 (796.9 Mb)<br>          Interrupt:28 Base address:0x4000}}
  
The line of interest is the second line, starting with 'inet addr:'. In the above example, our IP Address is '<tt>192.168.1.101</tt>' and our subnet mask is '<tt>255.255.255.0</tt>'. Both of these examples are commonly used values.
+
The line of interest is the second line, starting with '<tt>inet addr:</tt>'. In the above example, our IP Address is '<tt>192.168.1.101</tt>' and our subnet mask is '<tt>255.255.255.0</tt>'. Both of these examples are commonly used values.
  
 
===Default Route===
 
===Default Route===

Revision as of 00:04, 21 May 2011


Basic Checks

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'.

Template:Cli

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.

Default Route

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.

Template:Cli

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

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.

Template:Cli

  • 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 8.8.8.8
nameserver 8.8.4.4
Note: Using OpenDNS is possible but can make later diagnostic testing difficult: "OpenDNS, surtout pas".

Further Testing

ping

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 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=51 time=171 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=51 time=170 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=51 time=170 ms
64 bytes from 8.8.8.8: icmp_req=4 ttl=51 time=170 ms

--- 8.8.8.8 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.

Note: You will need the 'dnsutils' package installed to perform this test.

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 66.211.214.131)
  • 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	66.211.214.131

;; 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	208.76.61.100
ns2.everydns.net.	61675	IN	A	208.76.62.100
ns3.everydns.net.	61675	IN	A	208.76.63.100
ns4.everydns.net.	61675	IN	A	208.76.60.100

;; 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