實(shí)驗(yàn)?zāi)康?/h2>
通過本實(shí)驗(yàn)可以掌握:
- 交換機(jī)管理地址配置及接口配置。
- 查看交換機(jī)的MAC地址表。
- 配置靜態(tài)端口安全、動(dòng)態(tài)端口安全和粘滯端口安全的方法
實(shí)驗(yàn)拓?fù)?/h3>
配置交換機(jī)端口安全的實(shí)驗(yàn)拓?fù)淙鐖D所示。
????????????????????????????????????????????????配置交換機(jī)端口安全的實(shí)驗(yàn)拓?fù)?/p>
實(shí)驗(yàn)步驟
(1)交換機(jī)基本配置
Switch>enable
Switch#conf t
Switch(config)#hostname S1
S1(config)#interface vlan 1
//配置交換機(jī)交換虛擬接口,用于交換機(jī)遠(yuǎn)程管理
S1(config-if)#ip address 192.168.1.50 255.255.255.0
S1(config-if)#no shutdown
S1(config-if)#exit
S1(config)#ip default-gateway 192.168.1.1
//配置交換機(jī)默認(rèn)網(wǎng)關(guān)
S1(config)#interface fastEthernet 0/11
S1(config-if)#duple auto //配置以太網(wǎng)接口雙工模式,默認(rèn)時(shí)雙工狀態(tài)是auto
S1(config-if)#speed auto //配置以太網(wǎng)接口的速率,默認(rèn)時(shí)速率是自適應(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ù)要點(diǎn)】
????????在以太網(wǎng)接口上使用auto-MDIX(自動(dòng)介質(zhì)相關(guān)接口交叉)功能可以解決直通和交叉鄉(xiāng)纜的自適應(yīng)問題,該功能默認(rèn)啟用,但是接口的速率和雙工模式必須是 auto,否則該功能生效。
(2)查看交換機(jī)的MAC地址表
????????首先在計(jì)算機(jī) PCI、PC2和 Serverl上配置正確的IP地址,并且用 ipconfig /all命令查看各臺(tái)計(jì)算機(jī)網(wǎng)卡的MAC地址,記下來,然后在計(jì)算機(jī)PCl上分別ping PC2和 Serverl,進(jìn)行連通性測試,接下來查看交換機(jī)MAC地址表。
S1#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0001.6406.207b DYNAMIC Fa0/11 //計(jì)算機(jī)Server1網(wǎng)卡的MAC地址
1 0040.0b44.3494 DYNAMIC Fa0/10 //計(jì)算機(jī)PC0網(wǎng)卡的MAC地址
1 00d0.97c1.6a09 DYNAMIC Fa0/12 //計(jì)算機(jī)PC1網(wǎng)卡的MAC地址
S1#
????????以上顯示了交換機(jī)S1上的MAC地址表,其中 vlan字段表示交換機(jī)端口所在的VLAN;Mac Address字段表示與端口相連的設(shè)備的MAC地址:Type字段表示填充MAC地址記錄的類型,DYNAMIC表示MAC記錄是交換機(jī)動(dòng)態(tài)學(xué)習(xí)的,STATIC表示MAC記錄是靜態(tài)配置或系統(tǒng)保留的:Ports字段表示設(shè)備連接的交換機(jī)端口。
1、可以通過下面命令查看交換機(jī)動(dòng)態(tài)學(xué)習(xí)的MAC地址表的超時(shí)時(shí)間或老化時(shí)間,默認(rèn)為300秒。
S1#show mac address-table aging-time
Global Aging Time: 300
Vlan Aging Time
---- ----------
S1#
2、可以通過下面命令修改VLAN 1的 MAC地址表的超時(shí)時(shí)間為120秒。
S1(config)#mac address-table aging-time 120 vlan 1
3、可以通過下面命令配置靜態(tài)填充交換機(jī)MAC地址表
S1(config)#mac address-table static 0001.6406.207b vlan 1 interface fastEthernet 0/11
(3)配置交換機(jī)靜態(tài)端口安全
????????在交換機(jī)S1上配置端口安全,F(xiàn)a0/10配置動(dòng)態(tài)端口安全;FaO/11配置靜態(tài)端口安全;FaO/12配置粘滯端口安全。因?yàn)榻粨Q機(jī)FaO/11端口連接Serverl服務(wù)器,服務(wù)器不會(huì)輕易更換,適合配置靜態(tài)端口安全。
S1(config)#interface fastEthernet 0/11
S1(config-if)#switchport mode access
//端口配置為接入模式,配置端口安全的端口不能是動(dòng)態(tài)協(xié)商模式
S1(config-if)#switchport port-security
//打開交換機(jī)的端口安全功能
S1(config-if)#switchport port-security maximum 1
//配置端口允許接入設(shè)備的MAC地址最大數(shù)目,默認(rèn)是1,即只允許一個(gè)設(shè)備接入
S1(config-if)#switchport port-security mac-address 0001.6406.207b
//配置端口允許接入計(jì)算機(jī)的MAC地址
S1(config-if)#switchport port-security violation shutdown
//配置端口安全違規(guī)懲罰模式,這也是默認(rèn)的懲罰行為
S1(config-if)#exit
此時(shí),從Server1 上?ping交換機(jī)的管理地址,可以 ping通。
4)驗(yàn)證交換機(jī)靜態(tài)端口安全
S1#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0001.6406.207b STATIC Fa0/11 //Server1的網(wǎng)卡MAC地址靜態(tài)加入MAC地址表
S1#
???????在S1端口Fa0/11接入另一臺(tái)計(jì)算機(jī),模擬非法服務(wù)器接入,交換機(jī)顯示的信息如下:
*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
????????以上輸出顯示了交換機(jī)啟用端口安全的端口、允許連接最大MAC地址的數(shù)量、目前連接MAC地址的數(shù)量、懲罰計(jì)數(shù)和懲罰模式。
S1#show port-security interface fastEthernet 0/11
Port Security : Enabled
Port Status : Secure-shutdown
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 : 0030.A3E5.7101:1
Security Violation Count : 1
? ? ? ? 移除非法設(shè)備后,重新連接Serverl到該接口,由于已經(jīng)配置了端口 errdisable自動(dòng)恢復(fù)所以交換機(jī)顯示自動(dòng)恢復(fù)的消息如下:
【提示】
如果沒有配置由于端口安全懲罰而關(guān)閉的端口自動(dòng)恢復(fù),則需要管理員在交換機(jī)的Fa0/11端口下執(zhí)行 shutdown和 no shutdown命令來重新開啟該端口,如果還是非法主機(jī)嘗試連接,則繼續(xù)懲罰,端口再次變?yōu)閑rr-disable狀態(tài)。
(5)配置交換機(jī)動(dòng)態(tài)端口安全
? ? ? ? 很多公司員工使用筆記本電腦辦公,而且位置不固定(如會(huì)議室),因此適合配置動(dòng)態(tài)端口安全,限制每個(gè)端口只能連接1臺(tái)計(jì)算機(jī),避免用戶私自連接AP或者其他的交換機(jī)而帶來安全隱患。交換機(jī) Fa0/10端口連接計(jì)算機(jī)不固定,適合配置動(dòng)態(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)驗(yàn)證動(dòng)態(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)式電腦辦公,位置固定,如果配置靜態(tài)端口安全,需要網(wǎng)管員到員工的計(jì)算機(jī)上查看MAC地址,工作量巨大。為了減輕工作量,適合配置粘滯端口安全,限制每個(gè)端口只能連接Ⅰ臺(tái)計(jì)算機(jī),避免其他用戶的計(jì)算機(jī)使用交換機(jī)端口而帶來安全隱患。交換機(jī)FaO/12端口連接計(jì)算機(jī)位置固定,適合配置粘滯端口安全,安全懲罰模式為restrict。
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
//配置交換機(jī)端口自動(dòng)粘滯訪問該端口計(jì)算機(jī)的 MAC地址
S1(config-if)#exit
(8)驗(yàn)證粘滯端口安全
從PC2 上 ping交換機(jī)192.168.1.1,然后驗(yàn)證。文章來源:http://www.zghlxwxcb.cn/news/detail-857077.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 : 00D0.97C1.6A09:1
Security Violation Count : 0
至此實(shí)驗(yàn)結(jié)束。文章來源地址http://www.zghlxwxcb.cn/news/detail-857077.html
到了這里,關(guān)于配置交換機(jī)SSH管理和端口安全——實(shí)驗(yàn)2:配置交換機(jī)端口安全的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!