Before you configure your network devices, you should learn how to use some ICMP (Internet Control Message Protocol) tools. ICMP packets help you root out problems with connectivity and routing.
ping (see http://ftp.arl.mil/~mike/ping.html) is one of the most basic network debugging tools. It sends ICMP echo request packets to a host. If the host gets the packet and feels nice enough, it sends an ICMP echo response packet in return.
Let's say that you run ping 10.1.2.21 and you get this output:
PING 10.1.2.21 (10.1.2.21): 56 data bytes 64 bytes from 10.1.2.21: icmp_seq=0 ttl=255 time=8.0 ms 64 bytes from 10.1.2.21: icmp_seq=1 ttl=255 time=3.2 ms 64 bytes from 10.1.2.21: icmp_seq=2 ttl=255 time=3.4 ms 64 bytes from 10.1.2.21: icmp_seq=4 ttl=255 time=3.4 ms 64 bytes from 10.1.2.21: icmp_seq=5 ttl=255 time=3.2 ms
The most important
Notice that there's a gap between 2 and 4 in this example. This usually means that there's some kind of connectivity problem. It is possible to get packets out of order, but if this happens, there's still some kind of problem because
sends only one packet a second. If a response takes more than a second to
The round-trip time is the total elapsed time between the moment that the request packet was transmitted and moment that the response packet arrived. If there are incomplete routes between the request source and the destination,
On a wired LAN, you should expect
Sadly, not all
Another useful ICMP-based program is
; it will come in handy when you reach the material on routing later in the chapter. Use
to see the exact
4 22.214.171.124 1.163 ms 0.997 ms 1.182 ms 5 126.96.36.199 1.312 ms 1.12 ms 1.463 ms 6 188.8.131.52 1.421 ms 1.37 ms 1.347 ms 7 184.108.40.206 55.642 ms 55.625 ms 55.663 ms 8 220.127.116.11 55.89 ms 55.617 ms 55.964 ms 9 18.104.22.168 55.851 ms 55.726 ms 55.832 ms 10 22.214.171.124 56.419 ms 56.44 ms 56.423 ms
Because this output shows a big latency jump between hop 6 and hop 7, that part of the route is probably some
You can put these ICMP tools to use when setting up a working network interface, as the
On a Linux system, you connect the Internet layer to the physical medium, such as an Ethernet network or a modem-based connection, with a
. Common network interface
The most important command for viewing or manually configuring the network interface settings is ifconfig . To see your current interface's settings, run this command:
You do not need the -a in Linux, but other Unix variants require this option. The output should look something like this:
eth0 Link encap:Ethernet HWaddr 00:40:05:A0:7F:96 inet addr:10.1.2.2 Bcast:10.1.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:806961 errors:1 dropped:0 overruns:0 frame:0 TX packets:811658 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 RX bytes:726765161 (693.0 Mb) TX bytes:110229902 (105.1 Mb) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:44 errors:0 dropped:0 overruns:0 frame:0 TX packets:44 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 RX bytes:3569 (3.4 Kb) TX bytes:3569 (3.4 Kb)
The left side contains interface names, and the right side contains the settings for each interface. You can see that each interface has an IP address ( inet addr ) and a subnet mask ( Mask ), but you should also take careful note of the lines containing UP and RUNNING , because these tell you that the interface is working.
interface is a virtual network interface that is called the
loopback because it "
Your system calls ifconfig from one of its init.d scripts at boot time to configure the lo loopback interface. It's the only part of the network that is actually the same on any Linux machine, so it's a great place to start when you're trying to figure out how your particular distribution sets up networks. For example, in Red Hat Linux, each network interface has a script in /etc/sysconfig/network-scripts . You should be able to find the loopback device configuration by digging around in /etc with grep ifconfig .
If you have a static IP address on an Ethernet interface, your system's boot sequence should set up the interface in a manner very similar to the loopback. However, you can manually configure an IP address and
ifconfig eth0 address netmask mask
If you do not connect your system to the network with a static IP address on an Ethernet network, but rather, have a link such as a PPP or PPP-over-Ethernet (PPPoE) DSL connection, or if you use DHCP to get host information, you do not configure your interface with ifconfig (see Sections 5.7, 5.8, and 5.9 for those cases). However, even with those other types of connections, ifconfig -a is very useful for debugging.