This section provides sFlow configuration examples.
As shown in Figure 1, traffic between network 1 and network 2 is exchanged through device A. Maintenance personnel need to monitor the traffic on interface 2 and devices to identify traffic anomalies and ensure normal operation on network 1.
To configure sFlow, configure device A as an sFlow agent and enable Flow sampling on interface 2 so that the agent collects traffic statistics. The agent encapsulates traffic statistics into sFlow packets and sends the sFlow packets from interface 1 to the sFlow collector. The collector displays the traffic statistics based on information in the received sFlow packets.
The configuration roadmap is as follows:
<DeviceA> system-view [~DeviceA]interface GigabitEthernet 0/1/1 [~DeviceA-GigabitEthernet0/1/1]ip address 10.1.10.1 24 [*DeviceA-GigabitEthernet0/1/1]commit [~DeviceA]interface GigabitEthernet 0/1/2 [~DeviceA-GigabitEthernet0/1/2]ip address 10.1.20.1 24 [*DeviceA-GigabitEthernet0/1/2]commit [~DeviceA]interface GigabitEthernet 0/1/3 [~DeviceA-GigabitEthernet0/1/3]ip address 10.1.30.1 24 [*DeviceA-GigabitEthernet0/1/3]commit [~DeviceA-GigabitEthernet0/1/3]quit
# Configure an IP address for an sFlow agent.
[~DeviceA]sflow [~DeviceA-sflow]sflow agent ip 10.1.10.1 [*DeviceA-sflow]commit
# Configure sFlow collector information.
[~DeviceA-sflow]sflow collector 2 [*DeviceA-sflow-collector-2]commit [~DeviceA-sflow-collector-2]sflow server ip 10.1.10.2 [*DeviceA-sflow-collector-2]commit [~DeviceA-sflow-collector-2]quit [~DeviceA-sflow]quit
[~DeviceA]slot 1 [~DeviceA-slot-1]sflow enable [*DeviceA-slot-1]commit [*DeviceA-slot-1]quit
[~DeviceA]interface GigabitEthernet 0/1/2 [~DeviceA-GigabitEthernet0/1/2]sflow flow-sampling collector 2 inbound [*DeviceA-GigabitEthernet0/1/2]commit [~DeviceA-GigabitEthernet0/1/2]sflow flow-sampling rate 4000 inbound [*DeviceA-GigabitEthernet0/1/2]commit [~DeviceA-GigabitEthernet0/1/2]quit
[~DeviceA]display sflow configuration sflow sflow agent ip 10.1.10.1 sflow collector 2 sflow server ip 10.1.10.2 slot 1 sflow enable interface GigabitEthernet0/1/2 sflow flow-sampling collector 2 inbound sflow flow-sampling rate 4000 inbound
Device A configuration file
# sysname DeviceA # interface GigabitEthernet0/1/1 ip address 10.1.10.1 255.255.255.0 # interface GigabitEthernet0/1/2 ip address 10.1.20.1 255.255.255.0 # interface GigabitEthernet0/1/3 ip address 10.1.30.1 255.255.255.0 # sflow sflow agent ip 10.1.10.1 sflow collector 2 sflow server ip 10.1.10.2 slot 1 sflow enable # interface GigabitEthernet0/1/2 sflow flow-sampling collector 2 inbound sflow flow-sampling rate 4000 inbound # return