企業要求接入層交換機上每個連接終端設備的接口均只允許一臺PC接入網絡(限制mac地址接入數量)。如果有員工試圖在某個接口下級聯一臺小交換機或集線器從而擴展上網接口,那么這種行為應該被發現或被禁止,如下圖所示: 缺省情況下,未使能端口安全功能。 缺省情況下,接口學習的安全MAC地址限制數量為1。 缺省情況下,接口學習的安全動態MAC地址不老化。 缺省情況下,接口未使能Sticky MAC功能。 使能接口Sticky MAC功能后,缺省情況下,接口學習的MAC地址限制數量為1。 配置要求: Switch1配置如下: 配置驗證:執行命令 配置要求: Switch配置如下: 配置驗證執行命令端口安全技術背景
另一些企業還可能會要求只有MAC地址為可信任的終端發送的數據幀才允許被交換機轉發到上層網絡,員工不能私自更換位置(變更交換機的接入端口),如下圖所示:
通過交換機的端口安全(port security)特性可以解決這些問題。端口安全概述
端口安全技術原理
安全MAC地址通常與安全保護動作結合使用,常見的安全保護動作有:
端口安全技術應用
?
”端口安全配置命令
[Huawei-GigabitEthe.NET0/0/1] port-security enable
?
[Huawei-GigabitEthernet0/0/1] port-security max-mac-num max-number
?
[Huawei-GigabitEthernet0/0/1] port-security mac-address mac-address vlan vlan-id
[Huawei-GigabitEthernet0/0/1] port-security protect-action { protect | restrict | shutdown }
?
”
protect
restrict
shutdown
[Huawei-GigabitEthernet0/0/1] port-security aging-time time [ type { absolute | inactivity } ]
?
[Huawei-GigabitEthernet0/0/1] port-security mac-address sticky
?
[Huawei-GigabitEthernet0/0/1] port-security max-mac-num max-number
?
[Huawei-GigabitEthernet0/0/1] port-security mac-address sticky mac-address vlan vlan-id
端口安全配置舉例
安全動態MAC
?
”
[Switch1] interface GigabitEthernet 0/0/1
[Switch1-GigabitEthernet 0/0/1] port-security enable
[Switch1-GigabitEthernet 0/0/1] port-security max-mac-num 1
[Switch1-GigabitEthernet 0/0/1] port-security protect-action restrict
[Switch1] interface GigabitEthernet 0/0/2
[Switch1-GigabitEthernet 0/0/2] port-security enable
[Switch1-GigabitEthernet 0/0/2] port-security max-mac-num 1
[Switch1-GigabitEthernet 0/0/2] port-security protect-action restrict
[Switch1] interface GigabitEthernet 0/0/3
[Switch1-GigabitEthernet 0/0/3] port-security enable
[Switch1-GigabitEthernet 0/0/3] port-security max-mac-num 2
[Switch1-GigabitEthernet 0/0/3] port-security protect-action shutdown
display mac-address security
,查看動態安全MAC表項。
[Switch1]display mac-address security
MAC address table of slot 0:
----------------------------------------------------------------------------------------------------------------
MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID
VSI/SI MAC-Tunnel
----------------------------------------------------------------------------------------------------------------
5489-98ac-71a9 1 - - GE0/0/3 security -
5489-98b1-7b30 1 - - GE0/0/1 security -
5489-9815-662b 1 - - GE0/0/2 security -
----------------------------------------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 3
Sticky MAC
?
”
[Switch] interface GigabitEthernet 0/0/1
[Switch-GigabitEthernet 0/0/1] port-security enable
[Switch-GigabitEthernet 0/0/1] port-security max-mac-num 1
[Switch-GigabitEthernet 0/0/1] port-security mac-address sticky
[Switch] interface GigabitEthernet 0/0/2
[Switch-GigabitEthernet 0/0/2] port-security enable
[Switch-GigabitEthernet 0/0/2] port-security max-mac-num 1
[Switch-GigabitEthernet 0/0/2] port-security mac-address sticky
[Switch] interface GigabitEthernet 0/0/3
[Switch-GigabitEthernet 0/0/3] port-security enable
[Switch-GigabitEthernet 0/0/3] port-security max-mac-num 1
[Switch-GigabitEthernet 0/0/3] port-security mac-address sticky
[Switch-GigabitEthernet 0/0/3] port-security mac-address sticky 5489-98ac-71a9 vlan 1
display mac-address sticky
,查看Sticky MAC表項。
[Switch1]display mac-address sticky
MAC address table of slot 0:
-------------------------------------------------------------------------------------------------------
MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID
VSI/SI MAC-Tunnel
-------------------------------------------------------------------------------------------------------
5489-98ac-71a9 1 - - GE0/0/3 sticky -
5489-98b1-7b30 1 - - GE0/0/1 sticky -
5489-9815-662b 1 - - GE0/0/2 sticky -
-------------------------------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 3