文章

根据ip地址或者mac地址找到设备接在哪个交换机下的哪个端口

根据ip地址或者mac地址找到设备接在哪个交换机下的哪个端口

假如已知ip地址10.1.250.14,首先到核心交换机下执行dis arp | include 10.1.250.14

[hexin]dis arp | include 10.1.250.14
IP ADDRESS      MAC ADDRESS     EXPIRE(M) TYPE        INTERFACE   VPN-INSTANCE
                                          VLAN/CEVLAN
------------------------------------------------------------------------------
10.1.250.14     be9e-be1b-dec0  0         D-0         GE3/0/22
------------------------------------------------------------------------------
Total:1646      Dynamic:1581    Static:0     Interface:65

可以查到mac地址和在哪个接口下

再执行dis lldp neighbor interface g3/0/22查找这个接口下接了哪台交换机

[hexin]dis lldp neighbor interface GigabitEthernet 3/0/22
GigabitEthernet3/0/22 has 1 neighbor(s):

Neighbor index :1
Chassis type   :macAddress
Chassis ID     :c0b8-e695-d1b6
Port ID type   :interfaceName
Port ID        :Gi0/50
Port description    :GigabitEthernet 0/50
System name         :mengwei
System description  :Ruijie Full Gigabit Security & Intelligence Access Switch (S2910-48GT4SFP-L) By Ruijie Networks
System capabilities supported   :bridge router
System capabilities enabled     :bridge router
Management address type  :ipv4
Management address value :10.2.2.210
Expired time   :109s


Port VLAN ID(PVID)  :1
VLAN name of VLAN  1:VLAN0001
Protocol identity   :

Auto-negotiation supported    :Yes
Auto-negotiation enabled      :Yes
OperMau   :speed(1000)/duplex(Full)

Power port class         :PD
PSE power supported      :No
PSE power enabled        :No
PSE pairs control ability:No
Power pairs              :Unknown

可以看到交换机的ip地址,可以看到是锐捷的设备,然后再执行show mac-address-table | include be9e.be1b.dec0

mengwei(config)#show mac-address-table | include be9e.be1b.dec0
 250        be9e.be1b.dec0       DYNAMIC  GigabitEthernet 0/49           2023-7-31 3:10:43

再重复之前的查交换机的动作,一步步下来就能查到哪个交换机哪个端口

如果是已知的是mac地址的话,第一步就不用查ARP,直接用dis mac-address | include be9e-be1b-dec0查到哪个端口就行,后面步骤一致

注:网络设备获取本机mac地址
huawei : dis bridge mac-address/dis system-mac
h3c:dis device manuinfo
ruijie: show sysmac

License:  CC BY 4.0