1、實驗?zāi)康?/h2>
通過本實驗可以掌握:
- 交換機管理地址配置及接口配置。
- 查看交換機的MAC地址表。
- 配置靜態(tài)端口安全、動態(tài)端口安全和粘滯端口安全的方法。
2、實驗拓撲
配置交換機端口安全的實驗拓撲如圖所示。
配置交換機端口安全的實驗拓撲
3、實驗步驟
(1)交換機基本配置
S1(config)#interface vlan 1
//配置交換機交換虛擬接口,用于交換機遠程管理
S1(config-if)#ip address 172.16.1.100 255.255.255.0
S1(config-if)#no shutdown
S1(config-if)#exit
S1(config)#ip default-gateway 172.16.1.1
//配置交換機默認網(wǎng)關(guān)
S1(config)#interface fastEthernet 0/11
S1(config-if)#duplex auto //配置以太網(wǎng)接口雙工模式,默認時雙工狀態(tài)是auto
S1(config-if)#speed auto //配置以太網(wǎng)接口的速率,默認時速率是自適應(yīng)即auto
S1(config-if)#mdix auto //配置auito-MDIX
S1(config-if)#exit
S1(config)#interface range f0/5-9,f0/13-24,g0/1,g0/2
S1(config-if-range)#shutdown
//以上2行批量禁用未使用的端口
【技術(shù)要點】
在以太網(wǎng)接口上使用auto-MDIX(自動介質(zhì)相關(guān)接口交叉)功能可以解決直通和交叉鄉(xiāng)纜的自適應(yīng)問題,該功能默認啟用,但是接口的速率和雙工模式必須是 auto,否則該功能生效
(2)查看交換機的MAC地址表
? ? ? ? 首先在計算機 PCI、PC2和 Serverl上配置正確的IP地址,并且用 ipconfig /all命令查看各臺計算機網(wǎng)卡的MAC地址,記下來,然后在計算機PCl上分別ping PC2和 Serverl,進行連通性測試,接下來查看交換機MAC地址表。
S1#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0001.c95d.d021 DYNAMIC Fa0/11 //計算機Server1網(wǎng)卡的MAC地址
1 000c.cfda.ae96 DYNAMIC Fa0/10 //計算機PC0網(wǎng)卡的MAC地址
1 0060.3e28.8723 DYNAMIC Fa0/12 //計算機PC1網(wǎng)卡的MAC地址
S1#
? ? ? ? 以上顯示了交換機S1上的MAC地址表,其中 vlan字段表示交換機端口所在的VLAN;Mac Address字段表示與端口相連的設(shè)備的MAC地址:Type字段表示填充MAC地址記錄的類型,DYNAMIC表示MAC記錄是交換機動態(tài)學(xué)習(xí)的,STATIC表示MAC記錄是靜態(tài)配置或系統(tǒng)保留的:Ports字段表示設(shè)備連接的交換機端口。
1、可以通過下面命令查看交換機動態(tài)學(xué)習(xí)的MAC地址表的超時時間或老化時間,默認為300秒。
S1#show mac address-table aging-time
Global Aging Time: 300
Vlan Aging Time
---- ----------
S1#
2、可以通過下面命令修改VLAN 1的 MAC地址表的超時時間為120秒。
S1(config)#mac address-table aging-time 120 vlan 1
3、可以通過下面命令配置靜態(tài)填充交換機MAC地址表。
S1(config)#mac address-table static 0001.c95d.d021 vlan 1 interface fastEthernet 0/11
(3)配置交換機靜態(tài)端口安全
? ? ? ? 在交換機S1上配置端口安全,F(xiàn)a0/10配置動態(tài)端口安全;FaO/11配置靜態(tài)端口安全;FaO/12配置粘滯端口安全。因為交換機FaO/11端口連接Serverl服務(wù)器,服務(wù)器不會輕易更換,適合配置靜態(tài)端口安全。
S1(config)#interface fastEthernet 0/11
S1(config-if)#switchport mode access
//端口配置為接入模式,配置端口安全的端口不能是動態(tài)協(xié)商模式
S1(config-if)#switchport port-security //打開交換機的端口安全功能
S1(config-if)#switchport port-security maximum 1
//配置端口允許接入設(shè)備的MAC地址最大數(shù)目,默認是1,即只允許一個設(shè)備接入
S1(config-if)#switchport port-security mac-address 0001.c95d.d021
//配置端口允許接入計算機的MAC地址
S1(config-if)#switchport port-security violation shutdown
//配置端口安全違規(guī)懲罰模式,這也是默認的懲罰行為
S1(config-if)#exit
S1(config)#errdisable recovery cause psecure-violation
//允許交換機自動恢復(fù)因端口安全而關(guān)閉的端口
S1(config)#errdisable recovery interval 30
//配置交換機自動恢復(fù)端口的周期,時間間隔單位為秒
此時,從Server1 上?ping交換機的管理地址,可以 ping通。
(4)驗證交換機靜態(tài)端口安全
S1#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0001.c95d.d021 STATIC Fa0/11 //Server1的網(wǎng)卡MAC地址靜態(tài)加入MAC地址表
在S1端口Fa0/11接入另一臺計算機,模擬非法服務(wù)器接入,交換機顯示的信息如下:
*Apr 3 07:43:43.080: %PM-4-ERR_DISABLE: psecure-violation error detected on Et0/1, putting Et0/1 in err-disable state
S1#
*Apr 3 07:43:43.080: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address aabb.cc00.0200 on port Ethernet0/1.
*Apr 3 07:43:44.084: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down
S1#
*Apr 3 07:43:45.080: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to down
? ? ? ? 以上輸出顯示了交換機啟用端口安全的端口、允許連接最大MAC地址的數(shù)量、目前連接MAC地址的數(shù)量、懲罰計數(shù)和懲罰模式。
S1#show port-security interface fastEthernet 0/11
Port Security : Disabled
Port Status : Secure-down
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses : 1
Total MAC Addresses : 1
Configured MAC Addresses : 1
Sticky MAC Addresses : 0
Last Source Address:Vlan : 0000.0000.0000:0
Security Violation Count : 0
? ? ? ? 移除非法設(shè)備后,重新連接Serverl到該接口,由于已經(jīng)配置了端口 errdisable自動恢復(fù)所以交換機顯示自動恢復(fù)的消息如下:
【提示】
如果沒有配置由于端口安全懲罰而關(guān)閉的端口自動恢復(fù),則需要管理員在交換機的Fa0/11端口下執(zhí)行 shutdown和 no shutdown命令來重新開啟該端口,如果還是非法主機嘗試連接,則繼續(xù)懲罰,端口再次變?yōu)閑rr-disable狀態(tài)。
(5)配置交換機動態(tài)端口安全
? ? ? ? 很多公司員工使用筆記本電腦辦公,而且位置不固定(如會議室),因此適合配置動態(tài)端口安全,限制每個端口只能連接1臺計算機,避免用戶私自連接AP或者其他的交換機而帶來安全隱患。交換機 Fa0/10端口連接計算機不固定,適合配置動態(tài)端口安全,安全懲罰模式為restrict。
S1(config)#interface fastEthernet 0/10
S1(config-if)#switchport mode access
S1(config-if)#switchport port-security
S1(config-if)#switchport port-security maximum 1
S1(config-if)#switchport port-security violation restrict
S1(config-if)#exit
(6)驗證動態(tài)端口安全
S1#show port-security interface fastEthernet 0/10
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Restrict
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses : 1
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address:Vlan : 0000.0000.0000:0
Security Violation Count : 0
(7)配置粘滯端口安全
? ? ? ? 很多公司員工使用臺式電腦辦公,位置固定,如果配置靜態(tài)端口安全,需要網(wǎng)管員到員工的計算機上查看MAC地址,工作量巨大。為了減輕工作量,適合配置粘滯端口安全,限制每個端口只能連接Ⅰ臺計算機,避免其他用戶的計算機使用交換機端口而帶來安全隱患。交換機FaO/12端口連接計算機位置固定,適合配置粘滯端口安全,安全懲罰模式為restrict。文章來源:http://www.zghlxwxcb.cn/news/detail-849250.html
S1(config)#interface fastEthernet 0/12
S1(config-if)#switchport mode access
S1(config-if)#switchport port-security
S1(config-if)#switchport port-security maximum 1
S1(config-if)#switchport port-security violation restrict
S1(config-if)#switchport port-security mac-address sticky
//配置交換機端口自動粘滯訪問該端口計算機的 MAC地址
S1(config-if)#exit
(8)驗證粘滯端口安全
從PC2 上 ping交換機172.16.1.100,然后驗證。文章來源地址http://www.zghlxwxcb.cn/news/detail-849250.html
S1#show port-security interface fastEthernet 0/12
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Restrict
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses : 1
Total MAC Addresses : 1
Configured MAC Addresses : 0
Sticky MAC Addresses : 1
Last Source Address:Vlan : 0060.3E28.8723:1
Security Violation Count : 0
到了這里,關(guān)于5.3.2 實驗2:配置交換機端口安全的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!