配置脚本:
进行流量统计,确认报文的收发情况。
步骤如下:
a、先定义acl,匹配ping的源、目的IP地址:
#
acl number 3333
rule 5 permit icmp source x.x.x.x 0 destination y.y.y.y 0
rule 10 permit icmp source y.y.y.y 0 destination x.x.x.x 0
#
b、再定义流分类、流行为
#
traffic classifier 3333
if-match acl 3333
#
traffic behavior 3333
statistic enable
#
traffic policy 3333
classifier 3333 behavior 3333
#
c、然后在端口上应用流策略,inbound方向和outbound方向,进行统计。
如:
#
interface GigabitEthernet5/0/34
traffic-policy 3333 inbound
traffic-policy 3333 outbound
#
d、进行ping操作,查看流量统计情况。
如:
display traffic policy statistics interface GigabitEthernet 5/0/34 inbound
display traffic policy statistics interface GigabitEthernet 5/0/34 outbound
如果outbound方向没有统计计数,说明报文没有发送出去;
如果inbound方向没有统计计数,说明没有收到应答报文;
统计计数清除命令参考:
reset traffic policy statistics interface GigabitEthernet 5/0/34 inbound
reset traffic policy statistics interface GigabitEthernet 5/0/34 outbound
环境:
SW1: 1.1.1.1
SW2: 2.2.2.2
互联vlan 1010 : 10.1.1.0/29
测试:
[Sw1]ping -s 9000 -c 1000 -a 1.1.1.1 2.2.2.2
PING 2.2.2.2: 9000 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=9000 Sequence=1 ttl=255 time=420 ms
Reply from 2.2.2.2: bytes=9000 Sequence=2 ttl=255 time=80 ms
Reply from 2.2.2.2: bytes=9000 Sequence=3 ttl=255 time=60 ms
Reply from 2.2.2.2: bytes=9000 Sequence=4 ttl=255 time=80 ms
Reply from 2.2.2.2: bytes=9000 Sequence=5 ttl=255 time=50 ms
Reply from 2.2.2.2: bytes=9000 Sequence=6 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=9000 Sequence=7 ttl=255 time=280 ms
Reply from 2.2.2.2: bytes=9000 Sequence=8 ttl=255 time=30 ms
Reply from 2.2.2.2: bytes=9000 Sequence=9 ttl=255 time=10 ms
结果显示:
[Sw1]display traffic policy statistics interface GigabitEthernet 0/0/9 inbound
Interface: GigabitEthernet0/0/9
Traffic policy inbound: 3000
Rule number: 2
Current status: OK!
---------------------------------------------------------------------
Board : 0
Item Packets Bytes
---------------------------------------------------------------------
Matched 257 333,346
+--Passed 257 333,346
+--Dropped 0 0
+--Filter 0 0
+--URPF - -
+--CAR 0 0
[Sw1]display traffic policy statistics interface GigabitEthernet 0/0/9 outbound
Interface: GigabitEthernet0/0/9
Traffic policy outbound: 3000
Rule number: 2
Current status: OK!
---------------------------------------------------------------------
Board : 0
Item Packets Bytes
---------------------------------------------------------------------
Matched 257 333,346
+--Passed 257 333,346
+--Dropped 0 0
+--Filter 0 0
+--URPF - -
+--CAR 0 0
附交换机配置:
[Sw1]dis current-configuration
#
sysname Sw1
#
vlan batch 1010
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
diffserv domain default
#
acl number 3000
rule 5 permit icmp source 1.1.1.1 0 destination 2.2.2.2 0
rule 10 permit icmp source 2.2.2.2 0 destination 1.1.1.1 0
#
traffic classifier 3000 operator and
if-match acl 3000
#
traffic behavior 3000
statistic enable
#
traffic policy 3000
classifier 3000 behavior 3000
#
drop-profile default
#
interface Vlanif1
#
interface Vlanif1010
ip address 10.1.1.1 255.255.255.248
#
interface GigabitEthernet0/0/9
port link-type access
port default vlan 1010
traffic-policy 3000 inbound
traffic-policy 3000 outbound
interface NULL0
#
interface LoopBack1
ip address 1.1.1.1 255.255.255.255
#
ip route-static 2.2.2.2 255.255.255.255 10.1.1.2
#
user-interface con 0
user-interface vty 0 4
#
<SW2>dis cu
#
sysname SW2
#
vlan batch 1010
#
interface Vlanif1
#
interface Vlanif1010
ip address 10.1.1.2 255.255.255.248
#
interface GigabitEthernet0/0/9
port link-type access
port default vlan 1010
#
interface LoopBack2
ip address 2.2.2.2 255.255.255.255
#
ip route-static 1.1.1.1 255.255.255.255 10.1.1.1
#
user-interface con 0
user-interface vty 0 4
#