3

I need to find out how many total physical ports my server has, and how many of them are in use and how many free. Can you kindly help how to find it:

This is what i find from dmidecode output:

    # dmidecode | egrep -i "PCI|Available|in use"
    PCI is supported
    ESCD support is available
    Designation: PCI-E Slot 1
    Type: x8 PCI Express
    Current Usage: In Use
    Designation: PCI-E Slot 2
    Type: x8 PCI Express
    Current Usage: Available
    Designation: PCI-E Slot 3
    Type: x4 PCI Express
    Current Usage: Available
    Designation: PCI-E Slot 4
    Type: x8 PCI Express
    Current Usage: In Use
    Designation: PCI-E Slot 5
    Type: x8 PCI Express
    Current Usage: In Use

    # dmidecode | grep -i "NIC"
    HP BIOS NIC PCI and MAC Information
    NIC 1: PCI device 04:00.0, MAC address 00:1E:0B:C0:F4:92
    NIC 2: PCI device 42:00.0, MAC address 00:1E:0B:C0:F4:90
    HP BIOS iSCSI NIC PCI and MAC Information
    NIC 1: PCI device 04:00.0, MAC address 00:1E:0B:C0:F4:93
    NIC 2: PCI device 42:00.0, MAC address 00:1E:0B:C0:F4:91

    [root@eir1 network-scripts]# cat ifcfg-eth[0123] | grep -i HWADDR
    HWADDR=00:1E:0B:C0:F4:92
    HWADDR=00:1E:0B:C0:F4:90
    HWADDR=00:26:55:e6:75:5c
    HWADDR=00:26:55:e6:75:5d

How do I conclude from this that how many physical ports are in use, and how many available ? kindly help

4 Answers 4

5

Here is what you need to do.

First list all NIC ports, each line is a port.

-bash-4.1# lspci | grep -i ethernet
03:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
03:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
04:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
04:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
08:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
08:00.1 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
0b:00.0 Ethernet controller: Solarflare Communications SFC9020 [Solarstorm]
0b:00.1 Ethernet controller: Solarflare Communications SFC9020 [Solarstorm]
0e:00.0 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
0e:00.1 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
0e:00.2 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
0e:00.3 Ethernet controller: Intel Corporation 82580 Gigabit Network Connection (rev 01)
11:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01)
11:00.1 Ethernet controller: Solarflare Communications SFC9120 (rev 01)

How do I know which port is which NIC interface ? (example, eth0)

-bash-4.1# ethtool -i eth0
driver: sfc
version: 4.1.2.1003b
firmware-version: 4.2.2.1003 rx1 tx1
bus-info: 0000:08:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no

Now you can see the bus-info: 0000:08:00.0 matches 08:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01).

Driver name is also a quick way to tell, in this case sfc indicates "Solarflare Communications"

So eth0 is one of the Solarflare port and is easy to check if it is up

ip link show eth0

Now you will be able to find out how many NIC ports you have, how many free ports on each card.

Thanks

2

You could try /sbin/ifconfig -a or ip link show and further ethtool.

The latter one shows connection states.

2
  • That only works if the drives are loaded though (e.g. it will not show a NIC which has no atttached drivers).
    – Hennes
    Nov 13, 2014 at 7:55
  • @sebastianwagner ifconfig from the net-tools package is deprecated for a while now. You should switch to using only the iproute2 package with its command ip. @Hennes the question was about knowing which ports are in use and which are available. Those information could only be known if a driver is loaded so I think it's a proper answer.
    – piernov
    Jul 26, 2015 at 22:23
2

I am not sure about exactly what you mean by physical ports. dmidecode can list connectors,

 # dmidecode --type 8 
 # dmidecode 2.12
 SMBIOS 2.5 present.

 Handle 0x0004, DMI type 8, 9 bytes
 Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: EXTERNAL MONITOR PORT
    External Connector Type: DB-15 female
    Port Type: Other

    Handle 0x0005, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: BUILT-IN LAN PORT
    External Connector Type: RJ-45
    Port Type: Network Port

    Handle 0x0006, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: USB PORT
    External Connector Type: Access Bus (USB)
    Port Type: USB

    Handle 0x0007, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: USB PORT
    External Connector Type: Access Bus (USB)
    Port Type: USB

    Handle 0x0008, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: USB/eSATA PORT
    External Connector Type: Access Bus (USB)
    Port Type: USB

    Handle 0x0009, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: HEADPHONE JACK
    External Connector Type: Mini Jack (headphones)
    Port Type: Other

    Handle 0x000A, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: HDMI-CONNECTOR
    External Connector Type: Other
    Port Type: Video Port

    Handle 0x000B, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator:  
    Internal Connector Type: None
    External Reference Designator: MICROPHONE JACK
    External Connector Type: Other
    Port Type: Other

or system slots,

  # dmidecode --type 9
  # dmidecode 2.12                                                                                                                                                                                
  SMBIOS 2.5 present.                                                                                                                                                                             

  Handle 0x000C, DMI type 9, 13 bytes                                                                                                                                                             
  System Slot Information                                                                                                                                                                         
    Designation: SD CARD                                                                                                                                                                    
    Type: Other                                                                                                                                                                             
    Current Usage: In Use                                                                                                                                                                   
    Length: Other                                                                                                                                                                           
    Characteristics:                                                                                                                                                                        
            3.3 V is provided                                                                                                                                                               
            Hot-plug devices are supported                                                                                                                                                  

  Handle 0x000D, DMI type 9, 13 bytes                                                                                                                                                             
  System Slot Information                                                                                                                                                                         
    Designation: EXPRESS CARD                                                                                                                                                               
    Type: x1 PCI Express                                                                                                                                                                    
    Current Usage: In Use
    Length: Other
    ID: 1
    Characteristics:
            3.3 V is provided
            Hot-plug devices are supported

What else do you need? You can find all relevant codes on the sourceforge page of dmidecode

2

To relate a card/port to a particular interface name, the following commands can also be handy.

The link in the /sys/class/net has the bus number which can map a port to an interface name.

root@xxx:~# ls -l /sys/class/net/
total 0
lrwxrwxrwx 1 root root    0 Aug  7 16:51 bond0 -> ../../devices/virtual/net/bond0
-rw-r--r-- 1 root root 4096 Aug  7 12:56 bonding_masters
lrwxrwxrwx 1 root root    0 Aug  7 16:51 eno1 -> ../../devices/pci0000:00/0000:00:01.1/0000:04:00.0/net/eno1
lrwxrwxrwx 1 root root    0 Aug  7 16:51 eno2 -> ../../devices/pci0000:00/0000:00:01.1/0000:04:00.1/net/eno2
lrwxrwxrwx 1 root root    0 Aug  7 16:51 eno3 -> ../../devices/pci0000:80/0000:80:01.0/0000:81:00.0/net/eno3
lrwxrwxrwx 1 root root    0 Aug  7 16:51 eno4 -> ../../devices/pci0000:80/0000:80:01.0/0000:81:00.1/net/eno4
lrwxrwxrwx 1 root root    0 Aug  7 16:51 enp6s0 -> ../../devices/pci0000:00/0000:00:02.0/0000:06:00.0/net/enp6s0
lrwxrwxrwx 1 root root    0 Aug  7 16:51 enp6s0d1 -> ../../devices/pci0000:00/0000:00:02.0/0000:06:00.0/net/enp6s0d1
lrwxrwxrwx 1 root root    0 Aug  7 16:51 enp8s0 -> ../../devices/pci0000:00/0000:00:03.0/0000:08:00.0/net/enp8s0
lrwxrwxrwx 1 root root    0 Aug  7 16:51 enp8s0d1 -> ../../devices/pci0000:00/0000:00:03.0/0000:08:00.0/net/enp8s0d1
lrwxrwxrwx 1 root root    0 Aug  7 16:51 enp9s0 -> ../../devices/pci0000:00/0000:00:03.2/0000:09:00.0/net/enp9s0
lrwxrwxrwx 1 root root    0 Aug  7 16:51 enp9s0d1 -> ../../devices/pci0000:00/0000:00:03.2/0000:09:00.0/net/enp9s0d1
lrwxrwxrwx 1 root root    0 Aug  7 16:51 lo -> ../../devices/virtual/net/lo
root@xxx:~# lspci -nn |grep Ether
04:00.0 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
04:00.1 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
06:00.0 Ethernet controller [0200]: Mellanox Technologies MT27500 Family [ConnectX-3] [15b3:1003]
08:00.0 Ethernet controller [0200]: Mellanox Technologies MT27500 Family [ConnectX-3] [15b3:1003]
09:00.0 Ethernet controller [0200]: Mellanox Technologies MT27500 Family [ConnectX-3] [15b3:1003]
81:00.0 Ethernet controller [0200]: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 [8086:1528] (rev 01)
81:00.1 Ethernet controller [0200]: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 [8086:1528] (rev 01)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .