Can the Linux OS determine which physical port on a multi-interface network card an active ethernet device in the Linux OS corresponds to?
There is no direct or guaranteed way to do this via the Linux OS, as it can depend on the server and network card hardware and firmware, however, there are multiple different ways to work out which ethernet device configured in the OS corresponds to which network adapter or port on a multi-interface network card.
Method 1: if you only have remote access to the server
If the server’s management module (such as a SUN ilom, HP ilo, or Dell DRAC module), shows mac addresses for each physical network interface configured on the server, then you can check and compare against the mac address configured for each network interface on the Linux OS.
Step 1. Note the mac address reported for each physical interface in the server’s management module.
Step 2: Check the output of the following command:
# ifconfig [interface]
then check the “ether” line for the mac address, and then find the matching mac address from step 1. Example:
# ifconfig eth0 eth0: flags=4163
mtu 1500 inet 10.x.x.x netmask 255.255.255.128 broadcast 18.104.22.168 ether 00:16:3e:79:34:c8 txqueuelen 1000 (Ethernet) ### mac address RX packets 68295324 bytes 67544049816 (62.9 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 52566893 bytes 57714346200 (53.7 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Step 3: Alternatively, run the following command on the network interface:
# ethtool --identify ethX
Example with eth0:
# ethtool --identify eth0 DEVICE=eth0 HWADDR=00:16:3E:79:34:C8
Method 2: If you have physical access to the server
If you have physical access to the server and if the physical network interfaces have a light on the case of the server, the ethtool command can be used to help identify which port on the card corresponds to the ethernet device configured in the OS.
Step 1: Run the following command, and the light should blink on the physical network interface being used by eth0:
# ethtool --identify eth0
Step 2: if the above is not supported, and if you have a maintenance window, do the following:
a) unplug one cable at a time, and check the ethtool output to see if the link has gone down on each device when the cable has been removed.
# ethtool eth0
Settings for eth0:
# ethtool eth0 Settings for eth0: [snip other output] Link detected: no
This shows the link for eth0 went down when the cable was pulled from a specific port.