With Centos installed on a server with 2 onboard ethernet ports, how can I check which port has an IP? In windows you can go to network & sharing center and you can see the network interface with a red X to show that the cable is unplugged. In Centos what command can I run to check which interface is connected or unplugged.


You've asked two different questions. To check if it has an IP address, you can use:

ip addr ls dev eth0  # the new iproute tools
ifconfig eth0        # old ifconfig

A down interface can still have an IP address. To check if the Ethernet link is up, you can:

ip link ls dev eth0  # look for LOWER_UP
ethtool eth0         # look for Link detected: yes

Note that a port may be "down" in software as well, in which case it may not have a link, despite being plugged in. You can check for that with:

ip link ls dev etho  # look for UP
ifconfig eth0        # look for UP / RUNNING (on the same line as the other flags)

The ip command supports a lot of advanced networking configuration that ifconfig/route/etc. do not. You should generally prefer them on Linux, but sometimes they're not installed (especially on older releases). You can still use ifconfig, etc., but those simply fail to display all the information—e.g., may not display a secondary IP address, or a second routing table.


Ifconfig is an obsolete command. The iproute2 suite supersedes it, along with a large number of other utilities, including bridge-utils, route, and so on.

The correct command is

 ip addr show dev eth0

which shows whether eth0 (for instance) has an IP address assigned. You can check whether the interface is up with

 ip link show dev eth0

and so on.


Open the terminal and type

ifconfig <interface_name> (eth0 for example)

If the cable is plugged you should see UP in first line of output:


There are a few way ... The easiest is by using nmcli d

nmcli d

[root@localhost ~]# nmcli d
enp0s8  ethernet  connected  Wired connection 1 
enp0s3  ethernet  connected  enp0s3             
lo      loopback  unmanaged  --                 
[root@localhost ~]# 


service network status

[root@localhost ~]# service network status
Configured devices:
lo enp0s3
Currently active devices:
lo enp0s3 enp0s8
[root@localhost ~]# 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.