Switch(config)#
interface fastEthernet 0/1
Switch(config-if)# switchport mode access (当端口连接是主机时,接入链路) Switch(config-if)# switchport port-security (启动端口安全) Switch(config-if)# switchport port-security mac-address 00E0.A342.20E6 (绑定一个MAC地址,默认只能绑定一个MAC地址) Switch(config-if)# switchport port-security violation ? protect Security violation protect mode (不转发数据) restrict Security violation restrict mode (不转发数据,上报网管平台) shutdown Security violation shutdown mode (关闭接口,并上报网管平台) Switch(config-if)# switchport port-security violation shutdown |
Switch(config)#
errdisable recovery interval ?
<30-86400> timer-interval(sec) 可以调整在30-86400秒,缺省是300秒。 |
Switch#
udld reset
No ports are disabled by UDLD.
同时,接口在被置为err-disable的时候,通常有一系列的日志产生,如下: *Mar 15 15:47:19.984: %SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port FastEthernet0/47 with BPDU Guard enabled. Disabling port. sw1# *Mar 15 15:47:19.984: %PM-4-ERR_DISABLE: bpduguard error detected on Fa0/47, putting Fa0/47 in err-disable state sw1# *Mar 15 15:47:21.996: %LINK-3-UPDOWN: Interface FastEthernet0/47, changed state to down |
Switch#show mac-address-table
Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0009.7c11.89e7
DYNAMIC Fa0/3 而这一条是动态学习到的
1 000a.41a9.79b0 DYNAMIC Fa0/2 这条也是动态学习到的 1 00e0.a342.20e6 STATIC Fa0/1 这一个端口的MAC地址我们可以看见是静态指定的。 Switch# |
Switch(config)#
interface fastEthernet 0/1
Switch(config-if)# switchport port-security violation restrict |
SW1(config)#
interface fastethernet 0/1
Switch(config-if)# Switch port-security maximum 3 设置绑定多少个MAC地址,而这里我设置的是3条 Switch(config-if)# Switchport port-security max-address *** 第一条的MAC地址。 Switch(config-if)# Switchport port-security mac-address *** 第二条的MAC地址。 Switch(config-if)# Switchport port-security max-address *** 第三条的MAC地址。 |
SW1(config)#
interface fastethernet 0/1
Switch(config-if)# Switch port-security maximum 3 设置绑定多少个MAC地址,而这里我设置的是3条 Switch(config-if)# switchport port-security mac-address sticky 这条命令就是将前三个接入到这个端口的计算机的MAC地址自动的加入到我们的MAC地址表中。 |
Switch(config)#
interface fastEthernet 0/2
Switch(config-if)# switchport mode access Switch(config-if)# switchport port-security Switch(config-if)# switchport port-security mac-address sticky |
Switch#
show mac-address-table
Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0009.7c11.89e7 DYNAMIC Fa0/3
1 000a.41a9.79b0 DYNAMIC Fa0/2 1 00e0.a342.20e6 STATIC Fa0/1 Switch# |
Switch#
show mac-address-table
Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0009.7c11.89e7 DYNAMIC Fa0/3
1 000a.41a9.79b0 STATIC Fa0/2 1 00e0.a342.20e6 STATIC Fa0/1 Switch# |
Switch#
show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action (Count) (Count) (Count) -------------------------------------------------------------------- Fa0/1 1 1 3 Restrict Fa0/2 1 1 0 Shutdown ---------------------------------------------------------------------- Switch# |