Essential commands for Linux network administration

by Mark Rais, senior editor reallylinux.com

In this article, Mark Rais shares a list of those essential networking commands every beginning Linux administrator needs to know.

Readers of this article also preferred to read: Linux Commands for Beginning Server Administrators

Every Linux administrator needs a list of networking commands essential for effective server use.

This article provides a summary of the most important or frequently used commands, and offers some tips for ensuring your server runs smoothly.

Please keep in mind that these tips assume you already have a configured Linux hostname and IP, with a working network card and connection.

This short but quite useful command allows you to check your network card for connectivity and review your IP address and host network information. Although I tend to use other commands more frequently, arp is useful when I want to very quickly check status on my network card.

host

The host command is something I use very regularly to check either the hostname of a specific server when I have the IP address, or the IP address when I have a specific hostname. The primary function of the host command is to enable a quick lookup of DNS server information. But don't underestimate the power of this command. The host command allows you to perform many different queries using the -t option. For instance, you can use the -t with TOC to specify that you wish to lookup a host geographical location: host -t LOC hostname (replace hostname with the fully qualified domain such as reallylinux.com)

ifconfig

The ifconfig command allows you to check and configure your server's network cards, assigning IP, DNS, and Gateway addresses. For example, to assign a specific IP address for the eth0 network card, you can use:

ifconfig eth0 10.1.1.1

(replace to 10.1.1.1 with an actual IP address)

You can get more details on this type of command on our Server Administration webpage.

Moreover, using the plain ifconfig command shows you the details of all the existing configured network cards and network interfaces. You can get more information about it in the reallylinux.com administrative command list. Using ifconfig is a very good way to check that your network hardware is working properly.

netstat

The netstat command offers you a simple way to review each of your network connections and open sockets. I frequently use the netstat with the head command to review the top few lines of output, which are helpful when performing web server administration. For example:

netstat | head

Also, by including the -r option, you get a very good summary of all of the network routing addresses.

ping

No basic network administration is effective without the ping command. I use it for testing server configuration and checking status. The ping command basically sends test packets to a specific server and checks if there is a response. The command is very helpful when trying to determine where a connectivity error originates.

ping 10.1.1.1

(replace the 10.1.1.1 with the specific IP address of the server you wish to check)

When you run the command, please remember to press Ctrl and C to stop the process. More details are available in our administrative command list.

Ping is a useful command and should be one of your first tests when a network failure occurs. If it works but for instance HTTP connections don't, then you know that the server network connectivity is correct, so the fault may instead be with the HTTP daemon or a problem with firewall settings. You can get more information about it in the reallylinux.com administrative command list. More importantly, if even the ping command fails to work, you know that there is a more significant server connectivity issue. It is a very fast way to check servers, even remotely.

whois

This command allows you to check the Internic database for proper hostnames. This is very handy when you are trying to trace back an IP address to a specific hostname, or the reverse. I often use it when troubleshooting connectivity between hosts and checking whether the problem is a host configuration error or an actual physical connectivity error. The most commonly used version of the command is:

whois -f 10.1.1.1

(replace the 10.1.1.1 with a specific server IP)

The -f option forces the command to skip any cache that may have stored the host state, and instead goes to the actual server to perform a lookup and verify its hostname.

Another useful variation of the command, especially for trying to identify port problems is:

whois --port=8102 10.1.1.1



Linux is a registered trademark of Linus Torvalds. Microsoft, Microsoft Windows and WindowsXP are trademarks or registered trademarks of Microsoft Corporation both in the United States and Internationally. RedHat is a registered trademark of RedHat Inc., SUN and JAVA are registered trademark of Sun Microsystems, Inc. All other trademarks or registered trademarks in this opinion piece belong to their respective owners.