Checking connectivity

Just knowing what device our box is using as its gateway is one thing, but actually being able to reach it is another thing entirely.

If you're standing before a box, there's a good chance you've been summoned to try and work out what's not working. Trying to ping the gateway is a good first step:

$ ping 10.0.2.2
PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.
64 bytes from 10.0.2.2: icmp_seq=1 ttl=64 time=0.768 ms
64 bytes from 10.0.2.2: icmp_seq=2 ttl=64 time=0.333 ms
64 bytes from 10.0.2.2: icmp_seq=3 ttl=64 time=0.637 ms

Here, our gateway device responded, but if yours doesn't, or you get Destination Host Unreachable, then there's a good chance something is going wrong (or you've been given duff information by your colleague in the ivory toweralways check this first).

In the following code, we're checking the status of the interface itself, again using the ip command:

$ ip address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

You may be interested to know why we have three UP values here.

The initial UP value inside the chevrons is if the interface is physically up. The LOWER_UP value, also inside the chevrons, is shown if a cable is physically connected and up. The state UP value outside the chevrons is if the interface is administratively up, which can be changed to DOWN through software.