Cisco switches useful commands

yoloooo / 2023-07-27 / 原文

useful show commands 34

COMMAND

DESC

sh log

Will show the log

sh run

Will show the switch config

sh run int g0/1

Will show the config for g0/1

sh int status

Will show all interfaces status

sh mac address-table

Will show mac address table

sh ip arp

Will show ARP table

sh cdp neighbors

Print Cisco connected devices

 

 

 

 

 

 

 

 

 

 

 

 

查看交换机里配置的路由

sh run | inc route

 

然后是知道某电脑的IP,怎么查其接的交换机哪个口?

1、首先查ARP表中该IP对应的mac

sh ip arp | inc 24.62

2、然后根据得到的mac在mac地址表里查对应的端口

sh mac address-table | inc e78d

 但比如ssh登录到的交换机是一个二层交换机,但要查的IP地址的电脑是连在三层交换机上的,怎么查?

按照Thibault的方法,二层交换机上现在应该没有缓存该ip的arp,所以sh ip arp | inc 10.25.24.62是空的

那就先ping一次,ping通了之后再sh ip arp | inc 10.25.24.62,就看得到该电脑的mac地址了,

然后sh mac address-table | inc e78d就可以查到在二层交换机上对应的端口,然后查看这个端口的状态

sh int status | inc Gi0/2

we can see switchport is configured in trunk mode, probably another switch, we dig

下面这个命令挺有用,可以看一台交换机上接了哪些设备

sh cdp neig

可以看到gi0/2是对应的sw01,最后ssh登录到sw01去就可以查找了