Because the loopback interface responds to all network commands in the same way as a remote host, it can be used to provide limited network testing, such as checking that the correct commands are installed and that all the required drivers are loaded. Because of this, it also provides a useful way of fault-finding network problems by providing another interface to test.
For example, the interface will respond to ping, and its statistics can be displayed using netstat:
hydrogen# ping localhost localhost is alive hydrogen#
The network is “alive,” so let's see how fast it appears to be or whether we are seeing any problems, such as packet loss:
hydrogen# ping -s localhost 64 5 PING localhost: 64 data bytes 72 bytes from localhost (127.0.0.1): icmp_seq=0. time=0. ms 72 bytes from localhost (127.0.0.1): icmp_seq=1. time=0. ms 72 bytes from localhost (127.0.0.1): icmp_seq=2. time=0. ms 72 bytes from localhost (127.0.0.1): icmp_seq=3. time=0. ms 72 bytes from localhost (127.0.0.1): icmp_seq=4. time=0. ms ----localhost PING Statistics---- 5 packets transmitted, 5 packets received, 0% packet loss round-trip (ms) min/avg/max = 0/0/0 hydrogen#
We see zero packet loss. The time taken to send and receive the packet is also reported as zero, which is exactly what we would expect as we are bypassing any physical network connections. To confirm the validity of the connection, we can use netstat to show that we have not had any packet errors or network collisions:
hydrogen# netstat -i -I lo0 Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue lo0 8232 loopback localhost 524 0 524 0 0 0 hydrogen#