bluebay2014 - Fotolia

Tip

The Linux ip command makes network config easy

The Linux ip command makes monitoring a Linux network configuration easy, but you need to know what to look for.

Windows administrators in modern data centers occasionally deal with Linux systems, for example when a vendor delivers its appliance as a VM running the Linux OS. Beginners need to know basics of Linux network configuration.

To start analyzing the network configuration on a Linux box, you'll need to find out what it currently uses. The Linux ip command is the way to go. This command offers an extensive range of options to discover the current network configuration of a machine.

The ip command works with arguments to specify what exactly displays. Use ip addr to find out about current networking, ip link to analyze status of network interfaces and ip route to see the routing table. All of these commands pair with the show command. So ip addr show (see Listing 1) will display current address configuration, ip link show lets you see statistics about a link, and ip route show gives the current routing table.

Listing 1. This output is an example of using the ip addr show command to see current address configuration.

[root@server1 ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:95:7f:5f brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.210/24 brd 192.168.122.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fd00::210/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe95:7f5f/64 scope link
       valid_lft forever preferred_lft forever

In its output, the ip addr show command shows all interfaces that exist on your Linux network config. Listing 1 shows two network interfaces. The interface named lo is the loopback interface, used for processes that communicate via the IP protocol. The important interface in the listing is eth0, the first Ethernet interface that was found on this server. On the interface you can see three important parts of the configuration: the MAC address, indicated as link/ether, the IPv4 address as well as the IPv6 address. Verify that this information matches what should be used on your server.

Linux networking stack has changed significantly since ifconfig's heyday -- you will miss information on today's networks if working with ifconfig.

Not all Linux systems will show eth0 as the standard Ethernet network card. Modern Linux kernels use the biosdevname utility, which aims to make it easier to identify a specific network interface. The device name is unique, such as eno1677736, but also is not standardized between different Linux systems. So if you see another device name that isn't eth0, don't panic -- that is expected and normal behavior.

Another useful interface to monitor the current Linux network config is the ip -s link command. This command shows current statistics about packets sent over a network interface. Linux's ip -s link (see Listing 2) helps if you're experiencing problems on a network interface and want to make sure that no packets drop in transit.

Listing 2. This ip -s link output allows an administrator to analyze network packet statistics.

[root@server1 ~]# ip -s link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    97196      270      0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    97196      270      0       0       0       0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:95:7f:5f brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    71870878   412311   0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    33588506   290604   0       0       0       0

After verifying the network configuration's viability, check routing. To show the current routing table, use ip route show (see listing 3). What you're looking for is the default route, which identifies the IP address of the gateway for accessing other networks.

Listing 3: Output from the Linux ip route show command helps verify routing table configuration.

[root@server1 ~]# ip route show
default via 192.168.122.1 dev eth0  proto static  metric 100
192.168.122.0/24 dev eth0  proto kernel  scope link  src 192.168.122.210  metric 100

What about ifconfig?

The ifconfig command that shows current networking information on Linux servers has been deprecated for over a decade. What's wrong about using it? The Linux networking stack has changed significantly since ifconfig's heyday -- you will miss information on today's networks if working with ifconfig. The ip command was introduced to manage all aspects of Linux network configuration as the stack changed, and development on the ifconfig command was discontinued.

Linux ifconfig is not accurate, for example, when the administrator wants to work with network cards configured with additional IP addresses. If the additional IP address was configured using the same routines as the ip command uses, you won't see them using ifconfig. For that reason, on many recent Linux distributions, the ifconfig command is no longer included.

Next Steps

Get started with Linux servers

Take command of Linux systems

How to mount Linux file systems

DHCP client configuration for Linux, Windows and macOS

Access storage devices on Linux systems

Dig Deeper on Data center ops, monitoring and management

SearchWindowsServer
Cloud Computing
Storage
Sustainability and ESG
Close