CentOS

How to check network interface status in CentOS8

CentOS 8 generally comes with a preinstalled Network Manager, which helps to configure available connections and keep them active. It provides tools based on both in-line command and graphical user interfaces to accomplish trouble-free setup and management of networks. An API controls network configuration through D-Bus and performing queries.
Some of the important features of Network Manager in CentOS 8 include:

  • A Network Manager that is reflexively activated upon booting is essential in CentOS 8.
  • Network Manager includes command-based tools such as nmcli and NMTUI and GUI-based tools such as NMConnection Editor, Network Connection Icon, and Control Center.
  • Alongside the traditional ifcfg files, the basic installation also provides the latest versions of nmcli tool-based ifup and ifdown scripts.

Before learning how to check network interface status in CentOS 8, you need to make sure that:

Your server is set up with a root password. The network Manager package is installed and running on the server. The following commands can be used to verify the active and enabled status of the Network Manager and print the runtime status.

# systemctl is-active NetworkManager

# systemctl is-enabled NetworkManager

# systemctl status NetworkManager

The nmcli command to check the same is given below.

nmcli -t -f RUNNING general

Another command to do the same is nmcli general, and only it shows general properties along with the state of Network Manager.

How to check Network Interface Status in CentOS8

There can be a few different ways to check if the server is connected to a network or not. The most common ways are listed below.

Step 1

The iproute2 suite offers utilities for controlling traffic and regulates TCP/IP Networking. The following command will show whether a particular interface is up or not. For instance, if the server has an ethernet port eth0, entering the following command will tell their status.

ip link show dev eth0

Step 2

The ip commands allow for a lot more advanced network settings, which makes it more preferable. But sometimes, it is not provided with the package, especially on older releases. It would be useful to use the ifconfig command in such a case. The above command is used to check whether an Ethernet link is available, i.e., whether the port has been unplugged. There is a link detected, and LOWER_UP is detected in the first line.

ip link is dev eth0

However, software issues are likely, and a link is down despite the port being plugged in. In that case, the following commands are used. These will look for the up/down status of the port and the running status of the network. The first line of output will show DOWN in case the cable is unplugged.

ip link is dev eth0

ifconfig eth0

Step 3

Amongst all the ways to check for network interface status, the easiest is to use nmcli.
Typing the following code will show a list of all the available devices.

nmcli dev status

To specifically check the active status of a connection, the following command is used.

nmcli con show

Conclusion

So it was a brief introduction and the process to check network interface status in CentOS88. CentOS is a great operating system, but many people are switching from CentOS to other operating systems nowadays. If you also want to do it, please visit our official website to learn how to switch from one operating system to another.

About the author

Ankit Sharma