web-dev-qa-db-ja.com

Linuxで合計NICカードと使用可能な物理ポートの合計を確認する方法

サーバーにある物理ポートの総数、使用中のポートの数、空きポートの数を確認する必要があります。あなたは親切にそれを見つける方法を手伝ってくれますか:

これは私が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

これから、使用中の物理ポートの数と使用可能なポートの数をどのように結論付けることができますか?親切に助けて

2
dig_123

これがあなたがする必要があることです。

最初にすべてのNICポートをリストします。各行は、ポートです。

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

どのポートがどのNICインターフェイスか)を知るにはどうすればよいですか?(例、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
_

これで、_bus-info: 0000:08:00.0_が08:00.0 Ethernet controller: Solarflare Communications SFC9120 (rev 01)と一致することがわかります。

ドライバー名も簡単にわかります。この場合、sfcは「SolarflareCommunications」を示します。

したがって、_eth0_はSolarflareポートの1つであり、稼働しているかどうかを簡単に確認できます。

_ip link show eth0_

これで、NICポートの数、各カードの空きポートの数を確認できます。

ありがとう

3
Ask and Learn

物理ポートが何を意味するのか正確にはわかりません。 dmidecodeはコネクタを一覧表示でき、

 # 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

またはシステムスロット、

  # 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

他に何か要りますか?関連するすべてのコードを見つけることができます dmidecodeのsourceforgeページで

1
MariusMatutiae

/sbin/ifconfig -aまたはip link show、さらにethtoolを試すことができます。

後者は接続状態を示しています。

1
sebastianwagner

カード/ポートを特定のインターフェイス名に関連付けるには、次のコマンドも便利です。

/ sys/class/netのリンクには、ポートをインターフェイス名にマップできるバス番号があります。

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