配置步驟
定義acl,匹配SwitchA訪問SwitchB的流量,在做流量統計時應盡量保證匹配的情況精確,避免抓取到其他業務流量,使流量統計不准確。
[H3C]acl number 999
[H3C-acl-adv-999]description traffic accounting for host SwitchA to host SwitchB
[H3C-acl-adv-999]rule 10 permit icmp source 2.2.2.2 0 destination 3.3.3.3 0
定義流分類,匹配acl定義的PCA訪問PCB的web流量。
[H3C]traffic classifier traffic_accounting_from_SwitchA_to_SwitchB
[H3C-classifier-traffic_accounting_from_SwitchA_to_SwitchB]if-match acl 999
定義流行為,統計報文個數
[H3C]traffic behavior traffic_accounting_from_SwitchA_to_SwitchB
[H3C-behavior-traffic_accounting_from_SwitchA_to_SwitchB]accounting packet
定義qos策略,關聯流分類和流行為
[H3C]qos policy traffic_accounting_from_SwitchA_to_SwitchB
[H3C-qospolicy-traffic_accounting_from_SwitchA_to_SwitchB]classifier traffic_accounting_from_SwitchA_to_SwitchB behavior traffic_accounting_from_SwitchA_to_SwitchB
在2/0/1的入方向和2/0/2的出訪問下發qos策略,來統計報文是否到達設備和是否被設備轉發給SwitchB。
[H3C]interface GigabitEthernet2/0/1
[H3C-GigabitEthernet2/0/1]qos apply policy traffic_accounting_from_SwitchA_to_SwitchB inbound
[H3C]interface GigabitEthernet2/0/2
[H3C-GigabitEthernet2/0/2]qos apply policy traffic_accounting_from_SwitchA_to_SwitchB outbound
使SwitchA訪問SwitchB,查看接口GigabitEthernet2/0/1流量統計結果
[H3C]display qos policy interface GigabitEthernet 2/0/1
Interface: GigabitEthernet2/0/1
Direction: Inbound
Policy: traffic_accounting_from_SwitchA_to_SwitchB
Classifier: traffic_accounting_from_SwitchA_to_SwitchB
Operator: AND
Rule(s) : If-match acl 999
Behavior: traffic_accounting_from_SwitchA_to_SwitchB
Accounting Enable:
5 (Packets)
根據結果看出有5個報文進行交換機。查看接口GigabitEthernet2/0/2流量統計結果
[H3C]display qos policy interface GigabitEthernet 2/0/2
Interface: GigabitEthernet2/0/2
Direction: Outbound
Policy: traffic_accounting_from_SwitchA_to_SwitchB
Classifier: traffic_accounting_from_SwitchA_to_SwitchB
Operator: AND
Rule(s) : If-match acl 999
Behavior: traffic_accounting_from_SwitchA_to_SwitchB
Accounting Enable:
5 (Packets)
有5個報文從交換機發出,說明從A到B轉發正常
配置文件
#
acl number 999
description traffic accounting for host SwitchA to host SwitchB
rule 10 permit icmp source 2.2.2.2 0 destination 3.3.3.3 0 acl number
#
traffic classifier traffic_accounting_from_SwitchA_to_SwitchB
if-match acl 999
#
traffic behavior traffic_accounting_from_SwitchA_to_SwitchB
accounting packet
#
qos policy traffic_accounting_from_SwitchA_to_SwitchB
classifier traffic_accounting_from_SwitchA_to_SwitchB behavior traffic_accounting_from_SwitchA_to_SwitchB
#
interface GigabitEthernet2/0/1
qos apply policy traffic_accounting_from_SwitchA_to_SwitchB inbound
#
interface GigabitEthernet2/0/2
qos apply policy traffic_accounting_from_SwitchA_to_SwitchB outbound
注意事項
-
對匹配的流量計一定要盡量精確,避免其他流量影響統計結果。
-
注意流量雙向性和qos策略下發的方向要正確下發。