Access Control Lists

A Cisco access control list (ACL) is one of those technologies that looks simple until you have to troubleshoot one that’s blocking something you didn’t expect. At its most basic, an ACL is a list of rules that tells a router or switch what traffic to permit or deny. You can filter on the source or destination IP address, the IP protocol, TCP or UDP ports, ICMP, time ranges, and other packet characteristics your platform supports.

ACLs are commonly applied to router and Layer 3 switch interfaces, but they have other uses too, such as controlling VTY access, filtering routing updates and classifying traffic for other features.

The important thing to understand is that an ACL isn’t a firewall. It’s a packet filter, without the stateful inspection, application awareness and broader security features you’d expect from a modern firewall. ACLs are still extremely useful, though, because they’re built into the network infrastructure and can enforce straightforward traffic rules close to where traffic enters or leaves a device.

Standard vs extended ACLs

For IPv4 on Cisco IOS and IOS XE, the two main types you’ll work with are standard and extended ACLs.

Standard ACL

A standard ACL filters mainly on the source IP address, which makes it useful when the only question is whether traffic from a particular source should be allowed. For example, to allow only the 192.168.10.0/24 network, and apply the list inbound on an interface:

text

access-list 10 permit 192.168.10.0 0.0.0.255

interface GigabitEthernet0/0
 ip access-group 10 in

This is an old-style numbered standard ACL. The 0.0.0.255 isn’t a subnet mask. It’s a wildcard mask, which is essential to understand when working with Cisco ACLs, and we’ll come back to it shortly.

Standard ACLs are generally placed close to the destination, because they can’t tell destinations apart. Apply one too close to the source and you can block that source from reaching several destinations you never meant to affect.

Extended ACL

Extended ACLs give you much more control, because they can filter on source and destination address, protocol, TCP or UDP ports, ICMP and other supported fields. This one permits HTTP from 192.168.10.0/24 to 10.10.20.0/24:

text

access-list 100 permit tcp 192.168.10.0 0.0.0.255 10.10.20.0 0.0.0.255 eq 80

interface GigabitEthernet0/1
 ip access-group 100 in

The rule is much more specific because it considers the source, the destination and the TCP port. Extended ACLs are generally placed close to the source, so unwanted traffic is stopped before it travels through the rest of the network.

Named ACLs are usually easier to manage

Older Cisco configurations often use numbered ACLs such as 10 or 101. For new configurations, I generally prefer named ACLs, because a meaningful name beats remembering what ACL 150 does:

text

ip access-list extended BLOCK_UNWANTED_TRAFFIC
 10 deny tcp any any eq 23
 20 deny tcp any any eq 21
 30 permit ip any any

The result is much easier to read:

text

Extended IP access list BLOCK_UNWANTED_TRAFFIC
    10 deny tcp any any eq telnet
    20 deny tcp any any eq ftp
    30 permit ip any any

Named ACLs also make it easier to manage individual entries by sequence number.

Old-style numbered ACLs vs numeric ACL names

The terminology around numbered ACLs causes genuine confusion. An old-style numbered ACL is created with the traditional access-list command:

text

access-list 101 permit tcp any any eq 443
access-list 101 permit tcp any any eq 80

Cisco’s IP Access List Entry Sequence Numbering documentation says the sequence-numbering feature doesn’t support old-style numbered access lists, meaning the kind that existed before named ACLs were introduced. It also notes something people miss: an access list can be named with a number, as long as you create it in standard or extended named access-list configuration mode. So this is a named ACL, even though its name is 101:

text

ip access-list extended 101
 10 permit tcp any any eq 443
 20 permit tcp any any eq 80

In practice, current IOS and IOS XE releases blur the line further. A list created with access-list 101 generally shows sequence numbers in show access-lists, and can be edited by sequence number from ip access-list extended 101 mode. Behaviour can vary by platform and release, though, so test it on yours before relying on it in a change window. Either way, a descriptive name such as USERS_OUT tells you far more than 101 does.

Cisco also notes that sequence numbering doesn’t support dynamic, reflexive or firewall access lists.

Wildcard masks explained

Wildcard masks are a frequent stumbling block when you first start configuring ACLs, because they work the opposite way to subnet masks. In a wildcard mask, 0 means “check this bit” and 1 means “ignore this bit”.

So 192.168.10.0 0.0.0.255 means: match the first three octets exactly and ignore the last one. It matches 192.168.10.1, 192.168.10.50 and 192.168.10.254, but not 192.168.11.1. The relationship looks like this:

text

Subnet mask:   255.255.255.0
Wildcard mask:   0.0.0.255

For a single host, use 192.168.10.25 0.0.0.0, or more simply host 192.168.10.25. Cisco also provides any as shorthand for 0.0.0.0 255.255.255.255. If you’re unsure about a wildcard mask, write down the subnet mask first and invert it. That habit avoids a lot of ACL mistakes.

ACL direction matters

An ACL applied to an interface is either inbound or outbound, from the interface’s point of view. in filters packets as they enter the interface, and out filters them as they leave:

text

interface GigabitEthernet0/0
 ip access-group USERS_IN in

interface GigabitEthernet0/1
 ip access-group USERS_OUT out

It sounds obvious, but direction is easy to get wrong when troubleshooting. Draw the traffic path before applying the ACL:

text

Client
   |
   | enters Gi0/0
   v
Router
   |
   | leaves Gi0/1
   v
Server

An inbound ACL on Gi0/0 sees the traffic as it arrives from the client, and an outbound ACL on Gi0/1 sees the same traffic as it leaves towards the server.

Cisco’s description of the processing order is worth knowing. An inbound list decides whether to keep processing a packet as soon as it arrives, discarding it if it’s denied. With an outbound list, the packet is routed to the outbound interface first and only then checked against the ACL. That’s why an inbound ACL is more efficient: a denied packet is discarded before the router does the work of routing it.

Locally generated traffic

By default, an outbound ACL on a routed interface filters transit traffic leaving the device, not traffic the device generates itself. Cisco IOS XE provides the global command ip access-list match-local-traffic if you specifically want outbound IPv4 ACLs to filter locally generated traffic too. Don’t assume an outbound interface ACL will filter pings, SSH sessions or syslog messages that the router originates.

How ACL processing works

Rules are processed top to bottom

Cisco evaluates ACL entries in order, and the first matching statement wins:

text

10 deny tcp any any eq 23
20 permit ip any any

Telnet matches sequence 10 and is denied, and everything else reaches sequence 20 and is permitted. Reverse them, and the Telnet deny is useless, because every IP packet has already matched the permit:

text

10 permit ip any any
20 deny tcp any any eq 23

A more specific rule has to appear before any broader rule that would also match the traffic.

There’s an implicit deny

At the end of a populated ACL there’s an implicit deny. Conceptually, a list with one permit behaves like this:

text

10 permit 192.168.10.0 0.0.0.255
20 deny everything else

You don’t see that final deny in the configuration, but any traffic that reaches the end without matching a permit is discarded. This catches people out when they create an ACL with a single permit statement and then discover everything else has stopped working.

An empty ACL is different

This is Cisco-specific behaviour worth knowing exactly. Cisco’s helpful hints for creating IP access lists advise building the access list before applying it, because an interface with an empty access list applied permits all traffic. So an empty ACL permits everything, while a populated ACL with no matching permit ultimately denies.

Cisco also spells out the consequence of getting the order wrong. If you apply an access list that doesn’t exist yet and then start configuring it, the first statement takes effect immediately, and the implicit deny behind it can cut off access straight away. That’s the real mechanism behind a lot of accidental lockouts: the ACL is applied while empty, everything keeps working, and the moment you type the first permit, the implicit deny springs into existence and blocks everything else. Build and review the ACL first, then apply it.

Only one ACL per direction

On Cisco IOS and IOS XE, you can apply one IPv4 ACL per interface, per direction. You can’t stack several IPv4 ACLs inbound on the same interface and expect each to be evaluated independently. If you need multiple conditions, put them in the same ACL.

Editing an existing ACL

This is where sequence numbers earn their keep. Suppose you have:

text

ip access-list extended USERS_OUT
 10 permit tcp 192.168.10.0 0.0.0.255 any eq 443
 20 permit tcp 192.168.10.0 0.0.0.255 any eq 80
 30 deny ip any any

You later need to permit SSH to a specific server. Insert it with a sequence number between 10 and 20:

text

ip access-list extended USERS_OUT
 15 permit tcp 192.168.10.0 0.0.0.255 host 10.20.30.40 eq 22

To remove an entry, delete it by sequence number rather than retyping the whole statement:

text

ip access-list extended USERS_OUT
 no 20

If the numbering becomes awkward, ip access-list resequence USERS_OUT 10 10 renumbers the entries starting at 10 and going up in tens. Before this feature existed, inserting an entry in the middle of a list meant removing everything after that point, adding the new entry, then re-entering everything you’d removed. Cisco describes that method as cumbersome and error-prone, which is a fair assessment.

Verify the ACL with hit counters

Creating the ACL is only half the job. You also need to confirm the traffic you expect is actually matching the rule you expect. Run show ip access-lists, or for a specific list:

text

show ip access-lists USERS_OUT

You’ll see each entry and, where supported, its match counter:

text

Extended IP access list USERS_OUT
    10 permit tcp 192.168.10.0 0.0.0.255 any eq 443 (1250 matches)
    20 permit tcp 192.168.10.0 0.0.0.255 any eq 80 (342 matches)
    30 deny ip any any (17 matches)

Those counters are your best troubleshooting tool. If a user says HTTPS is working but your HTTPS permit shows zero matches, the traffic isn’t hitting the rule you thought it was. If the final deny is accumulating matches, traffic is reaching the ACL but not matching any earlier permit. That gives you something concrete instead of guesswork.

To start a test from a clean baseline, reset the counters with clear ip access-list counters USERS_OUT, generate the traffic, and look again. It becomes obvious which line caught it.

Be very careful when applying an ACL

One ACL mistake can turn a five-minute change into a trip to the comms room: locking yourself out. Suppose you’re connected over SSH through GigabitEthernet0/0, and you apply an ACL inbound that doesn’t permit your own management traffic:

text

interface GigabitEthernet0/0
 ip access-group MANAGEMENT_FILTER in

Your session disappears. Before applying an ACL to the interface carrying your management session, make sure it explicitly permits the traffic you need:

text

ip access-list extended MANAGEMENT_FILTER
 10 permit tcp 10.10.10.0 0.0.0.255 host 192.0.2.1 eq 22
 20 deny ip any any

Don’t assume the ACL will somehow spare your existing session because you’re already connected. On a device you can’t reach physically, run reload in 10 before applying the ACL. If you lock yourself out, the router reboots to its saved configuration ten minutes later. Once you’ve confirmed the change works, cancel it with reload cancel.

What about dynamic, reflexive and time-based ACLs?

You may come across older Cisco documentation describing dynamic, reflexive and time-based ACLs. They’re worth recognising in existing configurations, but they don’t need to dominate a modern ACL guide.

Dynamic ACLs, sometimes called lock-and-key, permit traffic after an authentication process, and older implementations commonly used Telnet as part of that workflow. I wouldn’t introduce Telnet into a modern network to implement a legacy ACL design. Reflexive ACLs create temporary entries based on traffic sessions, but for new designs a stateful firewall is generally a better fit. Time-based ACLs make an entry active only during a defined time range, which can still be useful for specific operational needs. Remember that sequence numbering doesn’t apply to dynamic or reflexive ACLs.

IPv6 ACLs are different

On a dual-stack network, IPv6 uses separate ACL configuration and different syntax:

text

ipv6 access-list USERS_V6
 permit tcp 2001:db8:10::/64 any eq 443

interface GigabitEthernet0/0
 ipv6 traffic-filter USERS_V6 in

Note the different command, ipv6 traffic-filter rather than ip access-group. IPv6 ACLs use prefix lengths rather than wildcard masks, which is one less thing to get wrong. They also include implicit permits for IPv6 Neighbor Discovery messages ahead of the implicit deny, so basic neighbour discovery keeps working. If you add your own explicit deny ipv6 any any at the end, it comes before those implicit permits, and you’ll need to permit Neighbor Discovery yourself.

When troubleshooting a dual-stack network, check both IPv4 and IPv6 filtering. An application can behave differently depending on which protocol it actually used.

When an ACL isn’t the right tool

ACLs are excellent for straightforward network-layer filtering, such as “allow this subnet to reach this server on TCP 443”. They become less appropriate when you need stateful connection tracking, application identification, user identity, URL filtering, malware inspection, intrusion prevention or centralised security management. That’s where a firewall or another dedicated control usually fits better. An ACL can still be useful alongside a firewall, because the two aren’t competing technologies.

The commands themselves aren’t complicated. The hard part is understanding which traffic the device will see, which direction it’s travelling, which rule it will hit first, and what happens to everything that doesn’t match. Once those four things are clear, ACL troubleshooting becomes much more predictable.

Cisco ACL checklist

  1. Create and review the ACL before applying it to a production interface.
  2. Remember that an empty ACL applied to an interface permits everything, and that adding the first statement to an applied ACL activates the implicit deny straight away.
  3. Account for the implicit deny at the end of every populated ACL.
  4. Order entries so specific rules come before broad ones, because the first match wins.
  5. Confirm whether the ACL is applied inbound or outbound, and draw the traffic path.
  6. Remember that outbound ACLs normally filter transit traffic, not traffic the router originates.
  7. Use descriptive named ACLs and sequence numbers so entries can be added or removed cleanly.
  8. Double-check every wildcard mask by inverting the subnet mask.
  9. Permit your own management traffic, and set reload in 10, before applying an ACL to a management interface.
  10. Clear the counters, generate test traffic and check show ip access-lists to confirm the right lines match.
  11. On a dual-stack network, configure and check IPv6 filtering separately, including Neighbor Discovery.

Further reading

Leave a Reply

Your email address will not be published. Required fields are marked *