思科交換機端口限速實戰
簡介
CISCO3550交換機作為我們單位的核心網絡交換機,已經穩定運行了多年,功能上也能滿足我們的需求,但是其端口限速功能卻不像其它的一些交換機那樣容易實現,好在最近找到了實現的辦法,配置完成后,配合iperf這款測速軟件進行驗證,結果證明這個方法是行之有效的,下面是具體實現步驟。
一、創建ACL
由于這是一臺三層交換機,所以雖然是對端口進行限速,但是還要考慮這個端口上通過的網絡地址,本例中,我們選擇對CISCO3550交換機的第22口進行限速,該端口屬于VLAN66,IP地址段為10.66/16,所以首先要創建一個ACL,如下所示:
- 3550#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- 3550(config)#access-list 15 permit 10.66.0.0 0.0.255.255
二、創建class-map
- 3550#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- 3550(config)#class-map dkxs
- 3550(config-cmap)#match access-group 15
這一步操作的主要目的就是創建了一個class-map,在這里面引用了我們事先創建好的ACL 15,方便我們以后對22端口進行操作。
三、創建policy-map
出于測試的需要,我們創建了多個policy-map,分別設置不同的限制帶寬,如80k,1m,5m,10m,分別如下:
- 3550#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- 3550(config)#policy-map 80k
- 3550(config-pmap)#class dkxs
- 3550(config-pmap-c)# police 80000 8000 exceed-action drop
- 3550#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- 3550(config)#policy-map 1m
- 3550(config-pmap)#class dkxs
- 3550(config-pmap-c)# police 1000000 100000 exceed-action drop
- 3550#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- 3550(config)#policy-map 5m
- 3550(config-pmap)#class dkxs
- 3550(config-pmap-c)# police 5000000 500000 exceed-action drop
- 3550#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- 3550(config)#policy-map 10m
- 3550(config-pmap)#class dkxs
- 3550(config-pmap-c)# police 10000000 1000000 exceed-action drop
四、查看配置信息
- 3550#show run
- policy-map 5m
- class dkxs
- police 5000000 500000 exceed-action drop
- policy-map 1m
- class dkxs
- police 1000000 100000 exceed-action drop
- policy-map 80k
- class dkxs
- police 80000 8000 exceed-action drop
- policy-map 10m
- class dkxs
- police 10000000 1000000 exceed-action drop
#p#
五、通過iperf軟件進行驗證
即先在一臺服務器上運行iperf的服務器端,命令如下:
- F:\tools>iperf -s
- ------------------------------------------------------------
- Server listening on TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
然后在交換機的22口上分別應用表示不同速率的policy-map,每應用一次,通過一臺連接到22端口的筆記本電腦運行iperf的客戶端,進行端口速率測試,結果分別如下:
(交換機設置)
- 3550(config-if)#service-policy input 80k
(IPERF客戶端測試結果)
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1147 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-12.5 sec 104 KBytes 68.3 Kbits/sec
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1151 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-12.0 sec 104 KBytes 70.8 Kbits/sec
(交換機設置)
- 3550(config-if)#service-policy input 1m
(IPERF客戶端測試結果)
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1155 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-10.5 sec 1.08 MBytes 860 Kbits/sec
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1159 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-10.0 sec 1.09 MBytes 910 Kbits/sec
(交換機設置)
- 3550(config-if)#service-policy input 5m
(IPERF客戶端測試結果)
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1163 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-10.5 sec 5.84 MBytes 4.67 Mbits/sec
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1167 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-10.7 sec 5.98 MBytes 4.68 Mbits/sec
(交換機設置)
- 3550(config-if)#service-policy input 10m
(IPERF客戶端測試結果)
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1171 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-10.1 sec 11.8 MBytes 9.83 Mbits/sec
- F:\tools>iperf -c 10.66.66.8
- ------------------------------------------------------------
- Client connecting to 10.66.66.8, TCP port 5001
- TCP window size: 8.00 KByte (default)
- ------------------------------------------------------------
- [1912] local 10.66.123.66 port 1175 connected with 10.66.66.8 port 5001
- [ ID] Interval Transfer Bandwidth
- [1912] 0.0-10.2 sec 12.0 MBytes 9.87 Mbits/sec
為了使測試的結果更準確,每種速率下都進行了兩次測試,從測試的結果看,端口限速確實生效了。【編輯推薦】

















