Security · Topic 3 of 7
Access Control Lists
Configure and verify standard, extended, named and IPv6 ACLs on IOS XE: wildcard masks, rule order, direction, placement and sequence editing.
- 6 min
- An ACL is read from the top, and the first match wins.
- There is an implicit deny at the end of every ACL.
- Standard ACLs match the source only. Extended ACLs match more fields.
What it is
An access control list (ACL) is an ordered list of permit and deny rules that a router applies to packets.
ACLs filter traffic on interfaces, and they also identify traffic for other features, such as NAT, route maps and QoS. The router reads the list from the top and acts on the first rule that matches. If nothing matches, an implicit deny at the end drops the packet.
How it works
Rules match fields in the packet, and the list is applied in one direction on an interface.
Types of ACL
| Type | Matches on | Numbers |
|---|---|---|
| Standard | Source address only | 1 to 99 and 1300 to 1999 |
| Extended | Source, destination, protocol and ports | 100 to 199 and 2000 to 2699 |
| Named | Either kind, identified by a name | Not applicable |
Named ACLs are easier to read and to edit, so they are the usual choice today.
Wildcard masks
ACLs use a wildcard mask, which is the inverse of a subnet mask. A zero bit means the bit must match, and a one bit means it is ignored.
| Network | Subnet mask | Wildcard mask |
|---|---|---|
| 10.1.1.0/24 | 255.255.255.0 | 0.0.0.255 |
| 10.1.0.0/16 | 255.255.0.0 | 0.0.255.255 |
| One host | 255.255.255.255 | 0.0.0.0 |
The keyword host stands for a wildcard of 0.0.0.0, and any stands for 0.0.0.0 with 255.255.255.255.
Building an extended named ACL
R1(config)# ip access-list extended WEB-ONLY
R1(config-ext-nacl)# remark Allow web to the server
R1(config-ext-nacl)# permit tcp 10.1.1.0 0.0.0.255 host 192.0.2.10 eq 443
R1(config-ext-nacl)# permit tcp 10.1.1.0 0.0.0.255 host 192.0.2.10 eq 80
R1(config-ext-nacl)# deny ip any any log
The last line is not strictly needed, since the implicit deny exists. Writing it with log lets you see the counts and the log of packets that were dropped.
Building a standard ACL
R1(config)# ip access-list standard MGMT-HOSTS
R1(config-std-nacl)# permit 10.99.0.0 0.0.0.255
Applying an ACL
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip access-group WEB-ONLY in
The direction is from the router's point of view. in filters packets as they enter the interface, and out filters packets as they leave. You can apply one ACL per protocol, per direction, per interface.
Placement
The common rule has two parts.
- Put extended ACLs close to the source, so unwanted traffic is dropped early.
- Put standard ACLs close to the destination, because they match only the source and could block too much if placed near it.
Editing
Every rule has a sequence number, and the default step is 10. This lets you insert a rule without retyping the list.
R1(config)# ip access-list extended WEB-ONLY
R1(config-ext-nacl)# 15 permit tcp 10.1.1.0 0.0.0.255 host 192.0.2.10 eq 8080
R1(config-ext-nacl)# no 20
R1# show access-lists WEB-ONLY
R1(config)# ip access-list resequence WEB-ONLY 10 10
A new rule with a sequence number goes in that position. The command no 20 removes rule 20.
Without a sequence number, a new rule goes to the end. Rule order matters, so a broad rule early can hide a specific rule later.
Useful options
| Keyword | Use |
|---|---|
established | Match TCP segments with ACK or RST set, which are replies in an existing session |
eq, gt, lt, range | Match port numbers |
log | Log matches |
remark | Add a comment |
IPv6 ACLs
IPv6 ACLs are always named, and they are applied with a different command.
R1(config)# ipv6 access-list V6-FILTER
R1(config-ipv6-acl)# permit tcp 2001:db8:1::/64 host 2001:db8:2::10 eq 443
R1(config-ipv6-acl)# deny ipv6 any any log
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ipv6 traffic-filter V6-FILTER in
At the end of every IPv6 ACL there are implicit rules that permit neighbour discovery before the implicit deny. This matters because IPv6 needs neighbour discovery to work.
Verifying
R1# show access-lists
R1# show ip access-lists WEB-ONLY
R1# show ip interface GigabitEthernet0/1
show access-lists lists each rule with a count of matches. A rule with no matches may be in the wrong order, or the traffic may not be arriving. show ip interface shows which ACL is applied in each direction.
An outbound ACL does not filter traffic that the router itself creates. To filter access to the router lines, use access-class, as in the device access page.
What to remember for the exam
Eight facts cover most questions on this topic.
- An ACL is read from the top, and the first match wins.
- There is an implicit deny at the end of every ACL.
- Standard ACLs match the source only. Extended ACLs match more fields.
- A wildcard mask uses zero for must match and one for ignore.
- Extended ACLs go near the source, and standard ACLs go near the destination.
ip access-group NAME inoroutapplies an IPv4 ACL on an interface.- Sequence numbers let you insert and remove rules in a named ACL.
- IPv6 uses
ipv6 traffic-filterand has implicit neighbour discovery permits.
Think about the direction from the router's view. Traffic entering the interface is in, and traffic leaving is out.
Common mistakes
These four mistakes appear often.
Using a subnet mask instead of a wildcard mask. The rule will match the wrong addresses.
Putting a broad rule first. It matches before the specific rule that you wanted.
Forgetting the implicit deny. Traffic you did not mention is dropped.
Applying the ACL in the wrong direction. The ACL does nothing useful, or it blocks the wrong packets.
Applying an ACL with no permit rule drops everything, including your management session, so keep a permit for your own access.
Check yourself
Work through these three questions.
What wildcard mask matches the 10.1.1.0/24 network?
0.0.0.255, which ignores the last octet.
Where should an extended ACL normally be placed?
Close to the source, so unwanted traffic is dropped early.
What happens to a packet that matches no rule?
The implicit deny at the end of the ACL drops it.
Topic 3 of 7 in Security
Test yourself on Security
The full Cisco CCNP 350-401 ENCOR question bank has 854 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.