端口安全總結


=========
端口安全
=========
- 端口安全是第2層特性,能夠提供如下5種保護特性:
 > 基於主機MAC地址允許流量
 > 基於主機MAC地址限制流量
 > 在期望的端口上阻塞單播擴散
 > 避免MAC擴散攻擊
 > 避免MAC欺騙攻擊

- 合法的MAC地址才能使用端口。合法地址可以自動學習也可靜態定義合法MAC地址可靠的MAC地址。配置時候有三種類型。
靜態可靠的MAC地址:在交換機接口模式下手動配置,這個配置會被保存在交換機MAC地址表和運行配置文件中,交換機重新啟動后不丟失(當然是在保存配置完成后),具體命令如下:
Switch(config-if)#switchport port-security mac-address Mac地址
動態可靠的MAC地址:這種類型是交換機默認的類型。在這種類型下,交換機會動態學習MAC地址,但是這個配置只會保存在MAC地址表中,不會保存在運行配置文件中,並且交換機重新啟動后,這些MAC地址表中的MAC地址自動會被清除。
黏性可靠的MAC地址:這種類型下,可以手動配置MAC地址和端口的綁定,也可以讓交換機自動學習來綁定,這個配置會被保存在MAC地址中和運行配置文件中,如果保存配置,交換機重起動后不用再自動重新學習MAC地址,雖然黏性的可靠的MAC地址可以手動配置,但是CISCO官方不推薦這樣做。具體命令如下:
Switch(config-if)#switchport port-security mac-address sticky (sticky的功能,無論MAC是靜態,還是動態,重啟后仍然存在)
其實在上面這條命令配置后並且該端口得到MAC地址后,會自動生成一條配置命令
Switch(config-if)#switchport port-security mac-address sticky Mac地址
這也是為何在這種類型下CISCO不推薦手動配置MAC地址的原因。


1.基於主機MAC來允許流量
配置端口安全特性:
1.啟用端口安全特性:
router(config-if)#switchport port-security

2.限制被允許訪問的MAC地址的最大數目:
(config-if)#switchport port-security maximum{number}[vlan vlan-id]

3.靜態定義MAC地址,可以設置一個或多個MAC地址:
(config-if)#switchport port-security mac-address {mac-address}[vlan vlan-id]

4.定義當收到帶有違法MAC地址信息的幀的時候,端口所采用的動作.
(config-if)#switchport port-security violation {protect|restrict|shutdown}
  >>shutdown (關閉)交換機將永久性或在特定時間周期內error-disable狀態,即不可用
  >>restrict (限制)交換機繼續工作,但將把來自未授權主機的數據幀丟棄
  >>protect  (保護)當超過允許學習的最大MAC地址數的時候,交換機將繼續工作,但將把來自新主機的數據幀丟棄

5.啟用MAC地址的粘滯學習(sticky learning),即當交換機重啟后,MAC地址不需要重新學習,它們是被保持在交換機啟動配置文件里.可選:
(config-if)#switchport port-security mac-address sticky
注意:端口安全僅僅配置在靜態Access端口;
     在trunk端口、SPAN端口、快速以太通道、吉比特以太通道端口組或者被動態划給一個VLAN的端口上不能配置端口安全功能;
不能基於每VLAN設置端口安全;交換機不支持黏性可靠的MAC地址老化時間。protect和restrict模式不能同時設置在同一端口上。

eg:

授權MAC地址
server: 00-00-00-00-00-08
client: 00-00-00-00-11-18
需求:
1.實時媒體服務器插入交換機端口3/47,為了防止其他任何非授權設備插入相同的端口中。
2.接受授權MAC地址,任何非授權工作站插入端口2/2,交換機將關閉LAN端口2/2
4503(config)#interface FastEthernet 3/47
4503(config-if)#switchport
4503(config-if)#switchport mode access  /指定端口模式
4503(config-if)#switchport port-security
4503(config-if)#switchport port-security mac-address 0000.0000.0008 /配置MAC地址。 
4503(config-if)#switchport port-security maximum 1 /限制此端口允許通過的MAC地址數為1。 
4503(config-if)#switchport port-security aging static //打開靜態映射 
4503(config-if)#switchport port-security violation restrict
4503(config)#interface FastEthernet 2/2
4503(config-if)#switchport
4503(config-if)#switchport mode access
4503(config-if)#switchport port-security
4503(config-if)#switchport port-security mac-address 0000.0000.1118
4503(config-if)#switchport port-security maximum 1
4503(config-if)#switchport port-security aging static
4503(config-if)#switchport port-security violation shutdown /當發現與上述配置不符時,端口down掉。 

2.基於主機MAC來限制流量 (3550上才可以做)
 列表中定義的MAC將被限制流量
(config)#mac-address-table static 0010.7b80.7b9b vlan 1 drop

3.阻塞未知單(組)播擴散 (3550上才可以做)
 對未知MAC地址,SW將從本VLAN的其他端口轉發出去,但對於某些端口(端口安全只需要一個MAC/已到最大MAC)沒必要再轉發這些單(組)播。就可以在這些端口上設定這一特性,通常結合端口安全來做。
int f0/1
  switchport block [unicast | multicast]
show int f0/1 switchport
...Unknown unicast blocked: enabled
...Unknown multicast blocked: disabled


檢驗命令:顯示所有接口上應用端口安全的信息: Switch#show port-security

顯示具體接口上所應用端口安全的信息:Switch#show port-security interface interface x/y 如下圖

顯示合法的MAC 地址信息:Switch#show port-security address 如下圖

默認的端口安全配置:
以下是端口安全在接口下的配置-
特性:port-sercurity  默認設置:關閉的。
特性:最大安全mac地址數目 默認設置:1
特性:違規模式  默認配置:shutdown,這端口在最大安全mac地址數量達到的時候會shutdown,並發snmp陷阱。
配置向導:
下面是配置端口安全的向導-
·安全端口不能在動態的access口或者trunk口上做,換言之,敲port-secure之前必須的是switch mode acc之后。
·安全端口不能是一個被保護的端口。
·安全端口不能是SPAN的目的地址。
·安全端口不能屬於GEC或FEC的組。
·安全端口不能屬於802.1x端口。如果你在安全端口試圖開啟802.1x,就會有報錯信息,而且802.1x也關了。如果你試圖改變開啟了802.1x的端口為安全端口,錯誤信息就會出現,安全性設置不會改變。
配置案例:
1.在f0/12上最大mac地址數目為5的端口安全,違規動作為默認。
switch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
switch(config)#int f0/12
switch(config-if)#swi mode acc
switch(config-if)#swi port-sec
switch(config-if)#swi port-sec max 5
switch(config-if)#end
switch#show port-sec int f0/12
Security Enabled:Yes, Port Status:SecureUp
Violation Mode:Shutdown
Max. Addrs:5, Current Addrs:0, Configure Addrs:0
 
2.如何配置f0/12安全mac地址
switch(config)#int f0/12
switch(config-if)#swi mode acc
switch(config-if)#swi port-sec
switch(config-if)#swi port-sec mac-add 1111.1111.1111
switch(config-if)#end
switch#show port-sec add
 Secure Mac Address Table
------------------------------------------------------------
 
Vlan    Mac Address       Type                Ports
----    -----------       ----                -----
   1    1000.2000.3000    SecureConfigured     Fa0/12
3.配置端口安全超時時間兩小時。
switch(config)#int f0/12
switch(config)#swi port-sec aging time 120 
4.端口安全超時時間2分鍾,給配置了安全地址的接口,類型為inactivity aging:
switch(config-if)#swi port-sec aging time 2
switch(config-if)#swi port-sec aging type inactivity
switch(config-if)#swi port-sec aging static
show port-security interface f0/12可以看狀態.
其他show
show port-security 看哪些接口啟用了端口安全.
show port-security address 看安全端口mac地址綁定關系.
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM