Configuration Examples
The section provides an sFlow configuration example. You can comprehend the configuration procedures through the configuration roadmap.
Example for Configuring sFlow
Networking Requirements
As shown in Figure 14-58, traffic between Department1 and Department2 is exchanged through SwitchA. Maintenance personnel need to view the traffic on 10GE1/17/2 and device running status, to detect abnormal traffic.
Configuration Roadmap
Configure sFlow on SwitchA and set the sampling mode on 10GE1/17/2 so that SwitchA can forward sampled traffic from 10GE1/17/1 to the sFlow collector. The sFlow collector then shows the network traffic status according to the received sFlow packets.
The configuration roadmap is as follows:
- Configure an IP address for SwitchA.
- Configure sFlow agent and sFlow collector information.
- Set the sFlow sampling mode.
Procedure
- Configure an IP address for SwitchA and specify a routing
protocol.
<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/17/1 [*SwitchA-10GE1/17/1] port link-type trunk [*SwitchA-10GE1/17/1] port trunk pvid vlan 100 [*SwitchA-10GE1/17/1] port trunk allow-pass vlan 100 [*SwitchA-10GE1/17/1] quit
- Configure sFlow agent and sFlow 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 5000 to sample incoming and outgoing traffic.
[*SwitchA] interface 10ge 1/17/2 [*SwitchA-10GE1/17/2] sflow sampling collector 2 rate 5000 inbound outbound
# Configure counter sampling. Set the sFlow collector ID to 2 and sampling interval to 120.
[*SwitchA-10GE1/17/2] sflow counter collector 2 interval 120 [*SwitchA-10GE1/17/2] quit [*SwitchA] commit [~SwitchA] quit
- Verify the configuration.
# After the configurations are complete, view the global sFlow information.
<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 -------------------------------------------------------------------------------- NOTE: CID:collectorID LEN:length DIR:direction RAT:rate INT:interval IN :inbound OUT:outbound -------------------------------------------------------------------------------- Sampling Counter --------------------------------------------------------------------------------- Interface CID LEN DIR RAT CID INT --------------------------------------------------------------------------------- 10GE1/17/2 2 128 IN&OUT 5000 2 120 ---------------------------------------------------------------------------------
Configuration Files
Configuration file of SwitchA
# 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/17/1 port link-type trunk port trunk pvid vlan 100 port trunk allow-pass vlan 100 # interface 10GE1/17/2 sflow sampling collector 2 sflow sampling rate 5000 sflow sampling inbound sflow sampling outbound sflow counter collector 2 sflow counter interval 120 # return