如何仅查看端口上的活动 MAC 地址

网络工程 思科 cisco 命令
2021-07-19 06:46:49

我在配置了端口安全和粘性选项的交换机上有一个端口。

interface FastEthernet0/18
...
 switchport port-security maximum 2
 switchport port-security
 switchport port-security mac-address sticky
 switchport port-security mac-address sticky 78e7.d1b4.8e14
 switchport port-security mac-address sticky 0060.b955.c003 vlan voice
...
end

IP 电话不再连接到此端口。如果我在端口上显示 MAC 地址,则会显示两个地址。

#show mac address-table int fa0/18
 Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
 491 0060.b955.c003 STATIC Fa0/18
 413 78e7.d1b4.8e14 STATIC Fa0/18
Total Mac Addresses for this criterion: 2

如何仅查看活动 MAC 地址,而不包括不再存在的粘性地址?show mac address-table dynamic不显示那个仍然在那里,因为它现在是static由于被粘滞语句记录了。

通过active,我的意思是设备仍然连接并在该端口上发送数据包 - 而不是仍然被记录为粘性 mac 地址。

例如,Netdisco 在执行macsuck操作时以某种方式能够分辨出差异

select mac, port, active from node where port = 'FastEthernet0/18';

mac                 port                active
78:e7:d1:b4:8e:14   FastEthernet0/18    true
00:60:b9:55:c0:03   FastEthernet0/18    false
3个回答

只要 MAC 静态分配给端口,它就会始终出现在表中。就开关而言,它始终处于“活动状态”。

知道它存在的唯一方法是 ping 它,检查 dhcp 监听表等。MAC 端口学习将不起作用。

由于端口上的流量,交换机获悉特定 MAC 地址位于该端口上。它将在 MAC 地址表中保留它,直到条目超时(当该端口上来自该 MAC 地址的更多流量时重置)。您可以专门告诉端口 MAC 地址条目不应过期,就像您所做的那样。

Cisco 交换机允许您使用命令调整 MAC 地址表的超时期限mac address-table aging-time(某些 IOS 版本的破折号不同。)

在端口安全中配置粘性选项时,mac 地址将作为静态添加到 Mac 地址表中。为了从 Mac 地址中删除此地址,您可以使用全局配置命令

(config)#no mac address-table static xxxx.xxxx.xxxx vlan yy

该 mac 地址保留在 Secure Mac 地址表中,即使它不在 Mac 地址表中。您可以通过以下方式检查:

#show port-security address

要从 Secure Mac Address 表中删除 mac 地址,请转到接口配置并:

(config-if)#no switchport port-security
(config-if)#switchport port-security