Cisco Port Security

cisco port security 可以限制port 紀錄 mac address 的數量,可以應用在企業環境中避免

不屬於企業的設備連上內部網路

LAB :

需達成目標

設定 fa0/1 只記錄一個mac address

當NB 接上fa0/1 會無法ping 到192.168.1.200

portsecurity1

以上需求可以在fa0/1 下達port security 相關指令達成目標

相關指令(紅色部分)

Switch(config)#interface f0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-security
Switch(config-if)#switchport port-security mac-address sticky
Switch(config-if)#switchport port-security maximum 1
Switch(config-if)#switchport port-security violation shutdown

switchport port-security  : 該port 啟動port security

switchport port-security mac-address sticky : 自動學習mac 不須手動輸入

switchport port-security maximum 1 :只記錄一個mac address

switchport port-security violation shutdown : 偵測到不適紀錄的mac address 就關閉該port

查詢指令

show port-security

Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
               (Count)       (Count)        (Count)
——————————————————————–
        Fa0/1        1          1                 0         Shutdown
———————————————————————-

show port-security address   (查詢已經紀錄的合法mac accress)

Secure Mac Address Table
——————————————————————————-
Vlan    Mac Address    Type            Ports        Remaining Age
                                (mins)
—-    ———–    —-            —–        ————-
1    0060.5C7A.64D4    SecureSticky        FastEthernet0/1        –
——————————————————————————

portsecurity2

當NB接上 fa0/1 會看到port會自動shutdown

查看該介面會顯示

Switch#sh interfaces fastEthernet 0/1
FastEthernet0/1 is down, line protocol is down (err-disabled)

Note:

1.NB接上後port 被shutdown 如果將PC 又接回該port此時還是需要由管理員手動將port, shutdown & no shutdown  (因為err-disabled 訊息)

2. 如果要讓正常pc 接回後可以自動恢復可使用下列指令

  •   switchport port-security violation restrict (有違規通知訊息,會累加次數統計)
  •   switchport port-security violation portect (無違規通知訊息,不累加次數統計)

3. 清除 port-security mac address 指令  –> clear port-security stick address  xxxxx



本篇瀏覽人數: 5984
分類: Cisco篇。這篇內容的永久連結

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *