Example for Configuring sFlow
Applicable Products and Versions
- CE16800, CE6881, CE6881K, CE6820, CE6863K, CE6881E, and CE6863 running V200R019C10 or later versions
- CE9860EI and CE5881 series switches running V200R020C00 or later versions
- All models (except the CE12800E configured with ED-E, EG-E, or EGA-E series cards, CE6880EI, and CE5880EI) running all versions
For details about the mapping between software versions and switch models, see the Hardware Query Tool.
Networking Requirements
As shown in Figure 2-41, traffic between department 1 and department 2 is exchanged through SwitchA. Maintenance personnel need to view traffic on 10GE2/0/1 and devices to detect abnormal traffic.
A data center network of an enterprise is complex. To ensure security and stability of the network, the enterprise needs to monitor the network in real time and restrict login rights of the administrator. A network management system can meet the preceding requirements.
Configuration Roadmap
Configure sFlow on SwitchA and set the sampling mode on 10GE2/0/1 so that SwitchA can forward sampled traffic from 10GE2/0/1 to the sFlow collector. The collector then shows the network traffic status based on the received sFlow packets.
The configuration roadmap is as follows:
- Configure an IP address for the interface on SwitchA.
- Configure sFlow agent and collector information.
- Set the sFlow sampling mode.
Procedure
- Configure an IP address for the interface on SwitchA.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan 100 [*SwitchA-vlan100] quit [*SwitchA] interface vlanif 100 [*SwitchA-Vlanif100] ip address 10.1.1.1 24 [*SwitchA-Vlanif100] quit [*SwitchA] interface 10ge 1/0/1 [*SwitchA-10GE1/0/1] port link-type trunk [*SwitchA-10GE1/0/1] port trunk pvid vlan 100 [*SwitchA-10GE1/0/1] port trunk allow-pass vlan 100 [*SwitchA-10GE1/0/1] quit
- Configure sFlow agent and collector information.
# Specify an IP address of the sFlow agent.
[*SwitchA] sflow agent ip 10.1.1.1
# Configure sFlow collector information: ID 2, IP address 10.1.1.2, and description netserver.
[*SwitchA] sflow collector 2 ip 10.1.1.2 description netserver
- Set the sFlow sampling mode.
# Configure flow sampling. Set the sFlow collector ID to 2 and sampling rate to 32768 to sample incoming and outgoing traffic.
[*SwitchA] interface 10ge 2/0/1 [*SwitchA-10GE2/0/1] sflow sampling collector 2 rate 32768 inbound outbound
# Configure counter sampling. Set the sFlow collector ID to 2 and sampling interval to 120.
[*SwitchA-10GE2/0/1] sflow counter collector 2 interval 120 [*SwitchA-10GE2/0/1] quit [*SwitchA] commit [~SwitchA] quit
Verifying the Configuration
After the configurations are complete, view the global sFlow information. The following uses CE12800 as an example.
<SwitchA> display sflow configuration sFlow Version 5 ------------------------------------------------------------------------------- Agent IP Address : 10.1.1.1 ------------------------------------------------------------------------------- Collector ID: 2 IP Address : 10.1.1.2 UDP Port : 6343 Length : 1400 Description : netserver Transmission : - ------------------------------------------------------------------------------- NOTE: CID:collectorID LEN:length DIR:direction RAT:rate INT:interval IN :inbound OUT:outbound HEAD-ONLY:IPv4/IPv6 head length ------------------------------------------------------------------------------- Sampling Counter ------------------------------------------------------------------------------- Interface CID LEN DIR RAT CID INT ------------------------------------------------------------------------------- 10GE2/0/1 2 128 IN&OUT 32768 2 120 -------------------------------------------------------------------------------
Configuration File
SwitchA configuration file
# sysname SwitchA # vlan batch 100 # sflow agent ip 10.1.1.1 # sflow collector 2 ip 10.1.1.2 description netserver # interface Vlanif100 ip address 10.1.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk pvid vlan 100 port trunk allow-pass vlan 100 # interface 10GE2/0/1 sflow sampling collector 2 sflow sampling rate 32768 sflow sampling inbound sflow sampling outbound sflow counter collector 2 sflow counter interval 120 # return