ifconfig command stands for "interface configuration" and is used to display network configuration information.ifconfig [OPTIONS]
Note
The iwconfig command is similar to the ifconfig command, but it is dedicated to wireless network interfaces.
Not all network settings are important for this module, but it is important to note in the following example that the IPv4 address of the primary network device eth0 is 192.168.1.2 and that the device is currently active (UP):
root@localhost:~# ifconfigeth0Link encap:Ethernet HWaddr 02:42:c0:a8:01:02inet addr:192.168.1.2Bcast:192.168.1.255 Mask:255.255.255.0UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:59 errors:0 dropped:0 overruns:0 frame:0 TX packets:86 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4346 (4.3 KB) TX bytes:5602 (5.6 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:100 (100.0 B) TX bytes:100 (100.0 B)
Consider This
The lo device is referred to as the loopback device. It is a special network device used by the system when sending network-based data to itself.
The ifconfig command can also be used to temporarily modify network settings. Typically these changes should be permanent, so using the ifconfig command to make such changes is fairly rare.
The ping command is used to verify connectivity between two computers. It does this by sending packets to another machine on a network. If the sender receives a response it should be possible to connect to that machine.
Information is sent using “packets”; the encapsulated unit of data sent over a network. In order for the packets to find the other computer, they will need an address. The ping command uses IP addresses to identify a computer on the network that it wants to connect to.
By default, the ping command will continue sending packets until the break command (CTL + C) is entered at the console. To limit how many pings are sent, use the -c option followed by the number of pings to be sent. The example below shows ping being limited to 4 iterations with -c 4.
If the ping command is successful, you will see output like the following:
root@localhost:~# ping -c 4 192.168.1.2 PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data. 64 bytes from 192.168.1.2: icmp_req=1 ttl=64 time=0.051 ms 64 bytes from 192.168.1.2: icmp_req=2 ttl=64 time=0.064 ms 64 bytes from 192.168.1.2: icmp_req=3 ttl=64 time=0.050 ms 64 bytes from 192.168.1.2: icmp_req=4 ttl=64 time=0.043 ms --- 192.168.1.2 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 2999ms rtt min/avg/max/mdev = 0.043/0.052/0.064/0.007 ms root@localhost:~#
If the ping command fails, you will receive a message stating, Destination Host Unreachable:
root@localhost:~# ping -c 4 192.168.1.3 PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data. From 192.168.1.2 icmp_seq=1 Destination Host Unreachable From 192.168.1.2 icmp_seq=2 Destination Host Unreachable From 192.168.1.2 icmp_seq=3 Destination Host Unreachable From 192.168.1.2 icmp_seq=4 Destination Host Unreachable --- 192.168.1.3 ping statistics --- 4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3065ms pipe 4 root@localhost:~#
The ping command may fail even though the remote machine is connecting. This is because some administrators configure their machines, or even entire networks, not to respond to ping requests as a security measure. The ping command also works with a hostname, or domain name like yahoo.com. Using this first saves time, if that ping command is successful, there is proper name resolution AND the IP address is functioning properly as well.
Follow Along
Exit the root account using the exit command:
root@localhost:~# exit logout
