NVOS Linux provides NVUE, an NVOS Linux-specific user-space tool, to configure custom access control lists (ACLs) on management interfaces, including the eth0 and loopback interfaces.
Traffic Rules
Chains
ACLs in NVOS Linux classify and control packets to and from the switch, asserting policies at layers 3 and 4 of the Open Systems Interconnection (OSI) model by inspecting packet headers according to a list of rules.
The rules inspect or operate on packets at several points (chains) in the life of the packet through the system:
NVOS supports the following chains:
-
PREROUTING touches packets before the switch routes them.
-
INPUT touches packets after the switch determines that the packets are for the local system but before the control-plane software receives them.
-
OUTPUT touches packets from the control-plane software before they leave the switch.
-
POSTROUTING touches packets immediately before they leave the switch but after a routing decision.
Rules
Rules classify the traffic you want to control. You apply rules to chains.
Install and Manage ACL Rules with NVUE
You can use NVUE to manage ACL rule configurations on the system.
The following example accepts packets that match these criteria:
-
TCP packets
-
Source IP address—
10.0.14.2/32 -
Any source port
-
Destination IP address—
10.0.15.8/32 -
Any destination port
Perform the following steps:
-
Set the rule type, the matching protocol, the source IP address and port, the destination IP address and port, and the action. You must provide a name for the rule (EXAMPLE1 in the following commands):
admin@nvos:~$ nv set acl EXAMPLE1 type ipv4 admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip protocol tcp admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip source-ip 10.0.14.2/32 admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip tcp source-port ANY admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip dest-ip 10.0.15.8/32 admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip tcp dest-port ANY admin@nvos:~$ nv set acl EXAMPLE1 rule 10 action permit -
Apply the rule to an inbound or outbound interface with the
nv set interface <interface> aclcommand.-
For rules that affect the PREROUTING or POSTROUTING chain, apply the rule to an inbound or outbound interface accordingly. For example:
admin@nvos:~$ nv set interface eth0 acl EXAMPLE1 inbound admin@nvos:~$ nv config apply -
For rules that affect the INPUT or OUTPUT chain, apply the rule to an inbound control plane or outbound control plane interface accordingly. For example:
admin@nvos:~$ nv set interface eth0 acl EXAMPLE1 inbound control-plane admin@nvos:~$ nv config apply
-
To return the default assignment of ACLs to an interface, run nv unset interface acl followed by nv config apply.
To see the configured rule, run the NVUE nv show acl <rule-name> rule <ID> command:
admin@nvos:~$ nv show acl EXAMPLE1 rule 10
operational applied
------------------- ------------ ------------
match
ip
source-ip 10.0.14.2/32 10.0.14.2/32
dest-ip 10.0.15.8/32 10.0.15.8/32
protocol tcp tcp
tcp
[source-port] ANY ANY
[dest-port] ANY ANY
To remove this rule, run the nv unset acl <acl-name> and nv unset interface <interface> acl <acl-name> commands.
admin@nvos:~$ nv unset acl EXAMPLE1
admin@nvos:~$ nv unset interface eth0 acl EXAMPLE1
admin@nvos:~$ nv config apply
To show ACL statistics per interface, such as the total number of bytes that match the ACL rule, run the nv show interface <interface-id> acl <acl-id> statistics or nv show interface <interface-id> acl <acl-id> statistics <rule-id> command. For example:
admin@nvos:~$ nv show interface eth0 acl EXAMPLE1 statistics
Rule In Packet In Byte Out Packet Out Byte Layer Remark Action Summary
---- --------- ------- ---------- -------- ----- ------ ------ --------------------------------
10 0 0 ip permit match.ip.dest-ip: 10.0.15.8/32
match.ip.protocol: tcp
match.ip.source-ip: 10.0.14.2/32
match.ip.tcp.dest-port: ANY
match.ip.tcp.source-port: ANY
To list all NVUE ACL commands, run the nv list-commands acl command.
Rule Support
|
Rule Element |
Supported |
|---|---|
|
Matches |
Src/Dst, IP protocol
|
|
Standard Actions |
permit, deny, log (log with log prefix), empty (no action specified) |
|
Limiters |
Recent-list
|
Default Action
By default, a rule has no action. Packets that match a rule with no action are not affected, and the following rules continue to process them in order.
Common Examples
Control Plane Limiters
With NVUE, you can configure rate limits on traffic so that the switch drops incoming packets that exceed certain thresholds. NVUE provides two limiters: recent-list and hashlimit.
Recent-List Limiter
With the recent-list limiter, you can dynamically create a list of IP addresses and then match against that list in several ways. For example:
admin@nvos:~$ nv set acl EXAMPLE2 type ipv4
admin@nvos:~$
admin@nvos:~$ nv set acl EXAMPLE2 rule 10 match ip tcp dest-port 22
admin@nvos:~$ nv set acl EXAMPLE2 rule 10 match ip protocol tcp
admin@nvos:~$ nv set acl EXAMPLE2 rule 10 match ip recent-list action set
admin@nvos:~$ nv set acl EXAMPLE2 rule 10 match ip recent-list name TCP-SSH-LIMIT
admin@nvos:~$
admin@nvos:~$ nv set acl EXAMPLE2 rule 20 match ip tcp dest-port 22
admin@nvos:~$ nv set acl EXAMPLE2 rule 20 match ip protocol tcp
admin@nvos:~$ nv set acl EXAMPLE2 rule 20 match ip recent-list action update
admin@nvos:~$ nv set acl EXAMPLE2 rule 20 match ip recent-list update-interval 60
admin@nvos:~$ nv set acl EXAMPLE2 rule 20 match ip recent-list hit-count 100
admin@nvos:~$ nv set acl EXAMPLE2 rule 20 match ip recent-list name TCP-SSH-LIMIT
admin@nvos:~$ nv set acl EXAMPLE2 rule 20 action deny
admin@nvos:~$
admin@nvos:~$ nv set interface eth0 acl EXAMPLE2 inbound control-plane
admin@nvos:~$ nv config apply
The example above limits any source IP address that sends more than 100 packets per 60-second interval to the switch. If a source IP address exceeds this rate, the switch blocks all packets from that source IP address.
A recent-list limiter configuration consists of two consecutive rules. Both rules should contain the same matching criteria (protocol tcp and dest-port 22 in the example above) and the same recent-list name (TCP-SSH-LIMIT in the example above).
-
The first rule sets the recent-list action to
set. -
The second rule sets the recent-list action to
updateand specifies the threshold withhit-countandupdate-interval(100 packets per 60-second interval in the example above). -
The action of the second rule is
deny.
Hashlimit Limiter
The hashlimit limiter uses hash buckets to express a rate-limiting match for a group of connections with a single rule. You can group connections per hostgroup (source address, destination address, or both). With hashlimit, you can express "N packets per time quantum per group". For example:
admin@nvos:~$ nv set acl EXAMPLE3 type ipv4
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip tcp dest-port 22
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip protocol tcp
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip hashlimit name TCP-SSH-LIMIT
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip hashlimit rate-above 5/min
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip hashlimit burst 2
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip hashlimit expire 3000
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip hashlimit mode src-ip
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 match ip hashlimit source-mask 32
admin@nvos:~$ nv set acl EXAMPLE3 rule 10 action deny
admin@nvos:~$ nv set interface eth0 acl EXAMPLE2 inbound control-plane
admin@nvos:~$ nv config apply
The example above limits any source IP address that sends more than 5 packets per minute to the switch, with a burst of 2 packets. If a source IP address exceeds this rate, the switch blocks all packets from that source IP address for 3000 milliseconds, as specified in the expire parameter. After this period, the source IP address can send packets again.
You can configure the hashlimit limiter in a single ACL rule. You must configure the following hashlimit parameters: name, rate-above, burst, expire, and mode. The source-mask and destination-mask parameters are optional.
Filter Specific TCP Flags
The following example rule drops ingress IPv4 TCP packets that have the SYN bit set and the RST, ACK, and FIN bits reset. The rule applies inbound on interface eth0. After you configure this rule, you cannot establish new TCP sessions that originate from ingress management port eth0. You can establish TCP sessions that originate from any other port.
NVUE Commands
admin@nvos:~$ nv set acl EXAMPLE4 type ipv4
admin@nvos:~$ nv set acl EXAMPLE4 rule 20 match ip protocol tcp
admin@nvos:~$ nv set acl EXAMPLE4 rule 20 match ip tcp flags syn
admin@nvos:~$ nv set acl EXAMPLE4 rule 20 match ip tcp mask rst
admin@nvos:~$ nv set acl EXAMPLE4 rule 20 match ip tcp mask syn
admin@nvos:~$ nv set acl EXAMPLE4 rule 20 match ip tcp mask fin
admin@nvos:~$ nv set acl EXAMPLE4 rule 20 match ip tcp mask ack
admin@nvos:~$ nv set acl EXAMPLE4 rule 20 action deny
admin@nvos:~$ nv set interface eth0 acl EXAMPLE4 inbound
admin@nvos:~$ nv config apply
Control Who Can SSH into the Switch
Run the following commands to control who can SSH into the switch. In the following example, 10.10.10.1/32 is the interface IP address (or loopback IP address) of the switch, and hosts in 10.255.4.0/24 can SSH into the switch.
NVUE Commands
admin@nvos:~$ nv set acl example2 type ipv4
admin@nvos:~$ nv set acl example2 rule 10 match ip source-ip 10.255.4.0/24
admin@nvos:~$ nv set acl example2 rule 10 match ip dest-ip 10.10.10.1/32
admin@nvos:~$ nv set acl example2 rule 10 action permit
admin@nvos:~$ nv set acl example2 rule 20 match ip source-ip ANY
admin@nvos:~$ nv set acl example2 rule 20 match ip dest-ip 10.10.10.1/32
admin@nvos:~$ nv set acl example2 rule 20 action deny
admin@nvos:~$ nv set interface eth0 acl example2 inbound
admin@nvos:~$ nv config apply
Match on ECN Bits in the TCP IP Header
Explicit Congestion Notification (ECN) allows end-to-end notification of network congestion without dropping packets. You can add ECN rules to match on the ECN-Echo (ECE), Congestion Window Reduced (CWR), and ECN-Capable Transport (ECT) flags in the TCP IPv4 header.
By default, ECN rules match a packet with the bit set. You can reverse the match by using an exclamation point (!).
Match on the ECE Bit
After an endpoint receives a packet with the Congestion Experienced (CE) bit set by a router, it sets the ECE bit in the returning ACK packet to notify the other endpoint that it needs to slow down.
To match on the ECE bit:
NVUE Commands
admin@nvos:~$ nv set acl example2 type ipv4
admin@nvos:~$ nv set acl example2 rule 10 match ip protocol tcp
admin@nvos:~$ nv set acl example2 rule 10 match ip ecn flags tcp-ece
admin@nvos:~$ nv set acl example2 rule 10 action permit
admin@nvos:~$ nv set interface eth0 acl example2 inbound
admin@nvos:~$ nv config apply
Match on the CWR Bit
The CWR bit notifies the other endpoint of the connection that it received and reacted to an ECE.
To match on the CWR bit:
NVUE Commands
admin@nvos:~$ nv set acl example2 type ipv4
admin@nvos:~$ nv set acl example2 rule 10 match ip protocol tcp
admin@nvos:~$ nv set acl example2 rule 10 match ip ecn flags tcp-cwr
admin@nvos:~$ nv set acl example2 rule 10 action permit
admin@nvos:~$ nv set interface eth0 acl example2 inbound
admin@nvos:~$ nv config apply
Match on the ECT Bit
The ECT codepoints negotiate whether the connection is ECN-capable by setting one of the two bits to 1. Routers also use the ECT bits to indicate that they are experiencing congestion by setting both ECT codepoints to 1.
To match on the ECT bit:
NVUE Commands
admin@nvos:~$ nv set acl example2 type ipv4
admin@nvos:~$ nv set acl example2 rule 10 match ip protocol tcp
admin@nvos:~$ nv set acl example2 rule 10 match ip ecn ip-ect 1
admin@nvos:~$ nv set acl example2 rule 10 action permit
admin@nvos:~$ nv set interface eth0 acl example2 inbound
admin@nvos:~$ nv config apply
Set DSCP on Transit Traffic
The following examples use the mangle table to modify the packet as it transits the switch. The Differentiated Services Code Point (DSCP) values in the following examples are in decimal notation.
To set SSH as high-priority traffic:
admin@nvos:~$ nv set acl EXAMPLE1 type ipv4
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip protocol tcp
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip tcp dest-port 22
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 action set dscp 46
admin@nvos:~$ nv set interface eth0 acl EXAMPLE1 inbound
admin@nvos:~$ nv config apply
To set all traffic coming in on swp1 as AF13:
admin@nvos:~$ nv set acl EXAMPLE1 type ipv4
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 action set dscp 14
admin@nvos:~$ nv set interface eth0 acl EXAMPLE1 inbound
admin@nvos:~$ nv config apply
To set packets destined for 10.0.100.27 as best effort:
admin@nvos:~$ nv set acl EXAMPLE1 type ipv4
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip dest-ip 10.0.100.27/32
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 action set dscp 0
admin@nvos:~$ nv set interface eth0 acl EXAMPLE1 inbound
admin@nvos:~$ nv config apply
To use a range of ports for TCP traffic:
admin@nvos:~$ nv set acl EXAMPLE1 type ipv4
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip protocol tcp
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip source-ip 10.0.0.17/32
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip tcp source-port 10000:20000
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip dest-ip 10.0.100.27/32
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 match ip tcp dest-port 10000:20000
admin@nvos:~$ nv set acl EXAMPLE1 rule 10 action set dscp 34
admin@nvos:~$ nv set interface eth0 acl EXAMPLE1 inbound
admin@nvos:~$ nv config apply
Last updated: