Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Getting the most from ifconfig

Sandra Henry-Stocker | April 19, 2016
The ifconfig command can tell you a lot about your Unix server’s connection to your network and the role it’s playing in both generating and receiving network traffic.

RX and TX – Receive and transmit packet counts. These will probably be in the same general ballpark and larger if your system has been running a lot time or does a lot of communicating with other systems. Web servers will likely have much larger TX than RX counts. The RX and TX counts are cumulative. The RX and TX counts for loopback interfaces will likely be quite small. Try pinging the system with the “ping localhost” command and both numbers will go up.

RX and TX bytes – These show you very similar data, but as bytes rather than packets, so the numbers are considerably larger.

The errors, dropped, overruns, frame, and carrier counts will generally all be zeroes. You may be having problems with your network interface if you see numbers bigger than 0 – malformed frames or CRC (cyclical redundancy check) errors that might indicate a problem with the interface or a network cable.

Collisions should be 0 or at least a small number. Collisions indicate that the network is has so much traffic that packets are interfering with each other.

The ifconfig’s –a option allows you see all network interfaces. You can also look at a specific network interface so that you focus on that without having to scan data for other interfaces.

ifconfig –a        show all interfaces
ifconfig eth0      show just eth0

You can also bring an interface up or shut it down with variations of the ifconfig command or some convenient shortcuts.

Bring the interface up:

ifconfig eth0 up
ifup eth0

Shut the interface down:

ifconfig eth0 down
ifdown eth0

Assigning a different IP address, netmask, and broadcast address can be done piece by piece or all together in a single command such as this one:

ifconfig eth0 netmask broadcast

If you use unusual subnet sizes, you can work out the number yourself or find a nice IP calculator like to do the thinking for you. By providing a single IP address, the number of bytes in the netmask (e.g., 24 if your netmask is, you can get your netmask, network, broadcast, first and last host IPs, and subnet size all calculated for you. Then you can be extra comfortable before running a command like this one:

ifconfig eth0 netmask broadcast

The 240 in this netmask represents the first four bits (128 + 64 + 32 + 16) in the address while the 15 in the broadcast represents the last four (8 + 4 + 2 + 1) indicating the break between the network and host portions of each IP address. Then again, these addresses depend on the particular subnet you’re working with. If the host you’re working with is, you’ll see a different broadcast address.


Previous Page  1  2  3  4  Next Page 

Sign up for Computerworld eNewsletters.