在網路環境中,如果任何人帶私有裝置,任意接上公司內部網路,對於整體內部網路的安全性有很大的影響。例如有中毒的NB接上內部網路後,會一直傳送廣播,對整體網路流量都會有相對的影響。
這時我們就可以使用Port-Security 來限制每個Port能紀錄的Mac address的數量
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int range fa0/1-24
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport port-security
Switch(config-if-range)#switchport port-security mac-address sticky
Switch(config-if-range)#switchport port-security maximum 1
Switch(config-if-range)#switchport port-security violation shutdown
------------------------------------------------------------------------------------------------------------
** switchport mode access
將Port運作模式設定為access mode,接末端設備都要選這個模式
**switchport port-security
啟動 Port-Security機制,因此若不打這行,只打後面的話也是白打
**switchport port-security mac-address sticky
自動記錄學到Mac address,這樣就不用手動輸入
**witchport port-security maximum 1
紀錄Mac address的數量上限為一筆
**switchport port-security violation shutdown
一旦偵測到違反設定時,關閉該Port
------------------------------------------------------------------------------------------------------------
Verify
Switch#sh port-security (會列出有設定port-security的Port,本範例會列出24Port)
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
(Count) (Count) (Count)
--------------------------------------------------------------------
Fa0/1 1 0 0 Shutdown
Fa0/2 1 0 0 Shutdown
Fa0/3 1 0 0 Shutdown
Fa0/4 1 0 0 Shutdown
Fa0/5 1 0 0 Shutdown
Fa0/6 1 0 0 Shutdown
Fa0/7 1 0 0 Shutdown
Fa0/8 1 0 0 Shutdown
Fa0/9 1 0 0 Shutdown
Fa0/10 1 0 0 Shutdown
Fa0/11 1 0 0 Shutdown
Fa0/12 1 0 0 Shutdown
Fa0/13 1 0 0 Shutdown
Fa0/14 1 0 0 Shutdown
Fa0/15 1 0 0 Shutdown
Fa0/16 1 0 0 Shutdown
Fa0/17 1 0 0 Shutdown
Fa0/18 1 0 0 Shutdown
Fa0/19 1 0 0 Shutdown
Fa0/20 1 0 0 Shutdown
Fa0/21 1 0 0 Shutdown
Fa0/22 1 0 0 Shutdown
Fa0/23 1 0 0 Shutdown
Fa0/24 1 0 0 Shutdown
----------------------------------------------------------------------
Switch#sh port-security address
Secure Mac Address Table
-------------------------------------------------------------------------------
Vlan Mac Address Type Ports Remaining Age
(mins)
---- ----------- ---- ----- -------------
1 0001.C703.2652 SecureSticky FastEthernet0/1 -
------------------------------------------------------------------------------