Como descobrir o total de cartões NIC e o total de portas físicas disponíveis no linux

1

Eu preciso descobrir quantas portas físicas totais meu servidor possui e quantas estão em uso e quantas são gratuitas. Você pode ajudar gentilmente a encontrar:

Isto é o que eu encontro na saída dmidecode:

    # 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

Como eu concluo que quantas portas físicas estão em uso e quantas estão disponíveis? gentilmente ajuda

    
por dig_123 19.11.2013 / 11:15

4 respostas

1

Você pode experimentar /sbin/ifconfig -a ou ip link show e mais ethtool .

O último mostra estados de conexão.

    
por 19.11.2013 / 11:29
1

Aqui está o que você precisa fazer.

Primeiro, localize todas as portas NIC, cada linha é uma porta.

-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)

Como sei qual porta é qual interface NIC? (exemplo, 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

Agora você pode ver o bus-info: 0000:08:00.0 corresponde a 08:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01)

Portanto, eth0 é uma das portas do Solarflare e é fácil verificar se ela está ativa

ip link show eth0

Agora você poderá descobrir quantas portas NIC você tem, quantas portas livres em cada cartão.

Obrigado

    
por 27.11.2015 / 00:54
0

Não tenho certeza sobre exatamente o que você quer dizer com portas físicas . dmidecode pode listar conectores,

 # 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

ou slots do sistema,

  # 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

O que mais você precisa? Você pode encontrar todos os códigos relevantes na página sourceforge do dmidecode

    
por 13.11.2014 / 09:35
0

Para relacionar um cartão / porta a um nome de interface específico, os seguintes comandos também podem ser úteis.

O link na / sys / class / net tem o número do barramento que pode mapear uma porta para um nome de interface.

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)
    
por 08.08.2018 / 06:50