Why ACLs Still Matter on IOS-XE
Every few years someone declares the access list obsolete, and every few years I'm back on a switch at 2 a.m. fixing one. ACLs are the basic packet filter on Cisco gear. They also feed QoS class maps, NAT, route-map matching, VTY protection and SNMP restrictions. If you don't understand how they're evaluated, you'll eventually lock yourself out of a device or leave a hole nobody notices.
For the full reference on ACL types, placement and the standard vs extended comparison, read the complete Cisco ACL runbook. Wildcard masks are covered in Cisco ACL wildcard masks explained.
This article walks through the three flavours you'll use on IOS-XE: standard, extended and named. We'll build each one, apply it, verify it and then break it on purpose so you recognise the failure modes. All examples run on a Catalyst switch called sw-infrarunbook-01 in the solvethenetwork.com environment.
Prerequisites
You need a Catalyst 9000-series switch or an ISR/ASR router running IOS-XE 16.x or 17.x. The syntax here is identical across those trains. You need privileged EXEC access, and ideally out-of-band console access. I can't stress that enough. Applying an ACL to a management interface over SSH is the classic way to cut off the branch you're sitting on.
You should also be comfortable with wildcard masks. A wildcard mask is the inverse of a subnet mask: 0 means "this bit must match" and 1 means "don't care." So 10.10.20.0 0.0.0.255 matches the whole /24, and 10.10.20.5 0.0.0.0 matches exactly one host (which you can shorten to
host 10.10.20.5).
The lab topology we'll use:
- VLAN 10 (Users): 10.10.10.0/24, SVI 10.10.10.1
- VLAN 20 (Servers): 10.10.20.0/24, SVI 10.10.20.1
- VLAN 30 (Guest): 10.10.30.0/24, SVI 10.10.30.1
- VLAN 99 (Management): 192.168.99.0/24, SVI 192.168.99.2
- Admin workstation: 192.168.99.10
- Web server: 10.10.20.50, DNS server: 10.10.20.53
How ACL Processing Works
Three rules govern everything else. First, entries are evaluated top to bottom and the first match wins. Second, there is an invisible
deny ip any anyat the end of every ACL. Third, an ACL does nothing until you apply it somewhere, and direction matters:
infilters packets as they arrive on the interface,
outfilters them as they leave.
One more behaviour trips people up. Traffic originated by the switch itself, such as a ping or an SSH session from the CLI, is not filtered by an outbound ACL on that interface. Only transit traffic is. Keep that in mind when your test from the box succeeds but real clients fail.
Step 1: Standard ACLs
A standard ACL matches on source IP address only. Numbered standard lists use 1-99 and 1300-1999. They're blunt, but that's useful for jobs where the source is all you care about: restricting VTY access, SNMP communities, NTP peers or NAT source selection.
Here's a standard list that permits only the management subnet:
sw-infrarunbook-01(config)# access-list 10 remark MGMT-SUBNET-ONLY
sw-infrarunbook-01(config)# access-list 10 permit 192.168.99.0 0.0.0.255
sw-infrarunbook-01(config)# access-list 10 deny any log
The explicit
deny any logis optional since the implicit deny exists anyway, but I add it on purpose. The implicit deny never shows hit counters. An explicit one does, and the log keyword tells you who is knocking.
Because standard ACLs sit close to nothing in terms of granularity, the old rule of thumb applies: place them as close to the destination as possible. If you put one near the source, you block that source from everything downstream, not just the one thing you meant to protect.
Step 2: Extended ACLs
Extended ACLs match protocol, source, destination and, for TCP/UDP, port numbers. Numbered ones use 100-199 and 2000-2699. They're what you'll reach for when writing real security policy. The general form is:
access-list <number> {permit|deny} <protocol> <source> <wildcard> [port-match] <destination> <wildcard> [port-match] [options]
Say we want Guest users to reach DNS and the web server on HTTPS, and nothing internal otherwise:
sw-infrarunbook-01(config)# access-list 130 remark GUEST-POLICY
sw-infrarunbook-01(config)# access-list 130 permit udp 10.10.30.0 0.0.0.255 host 10.10.20.53 eq 53
sw-infrarunbook-01(config)# access-list 130 permit tcp 10.10.30.0 0.0.0.255 host 10.10.20.50 eq 443
sw-infrarunbook-01(config)# access-list 130 deny ip 10.10.30.0 0.0.0.255 10.0.0.0 0.255.255.255 log
sw-infrarunbook-01(config)# access-list 130 deny ip 10.10.30.0 0.0.0.255 172.16.0.0 0.15.255.255 log
sw-infrarunbook-01(config)# access-list 130 deny ip 10.10.30.0 0.0.0.255 192.168.0.0 0.0.255.255 log
sw-infrarunbook-01(config)# access-list 130 permit ip 10.10.30.0 0.0.0.255 any
That final permit gives Guest general internet access after the private ranges are blocked. Order is everything here. If the broad deny lines sat above the two specific permits, DNS and HTTPS to the servers would never work. Specific first, general later.
For extended ACLs the placement advice flips: put them as close to the source as you can, so unwanted traffic dies early instead of crossing your network first.
Step 3: Named ACLs
Named ACLs are what I use for nearly everything now. They behave like numbered lists but give you a readable name, and more importantly they let you edit individual entries by sequence number. With a numbered list on older code, you either deleted the whole thing or appended to the bottom. On IOS-XE numbered ACLs can actually be edited through the named-style submode too, but the name still documents intent better than "130."
sw-infrarunbook-01(config)# ip access-list extended USERS-TO-SERVERS
sw-infrarunbook-01(config-ext-nacl)# remark Allow web and DNS to server VLAN
sw-infrarunbook-01(config-ext-nacl)# 10 permit udp 10.10.10.0 0.0.0.255 host 10.10.20.53 eq 53
sw-infrarunbook-01(config-ext-nacl)# 20 permit tcp 10.10.10.0 0.0.0.255 host 10.10.20.50 eq 443
sw-infrarunbook-01(config-ext-nacl)# 30 permit tcp 10.10.10.0 0.0.0.255 host 10.10.20.50 eq 80
sw-infrarunbook-01(config-ext-nacl)# 40 permit icmp 10.10.10.0 0.0.0.255 10.10.20.0 0.0.0.255 echo
sw-infrarunbook-01(config-ext-nacl)# 100 deny ip any any log
Notice I numbered by tens and left a gap before 100. That spacing is deliberate. When someone asks for a new rule next month, you can slot it in as sequence 25 without rebuilding anything:
sw-infrarunbook-01(config)# ip access-list extended USERS-TO-SERVERS
sw-infrarunbook-01(config-ext-nacl)# 25 permit tcp 10.10.10.0 0.0.0.255 host 10.10.20.50 eq 8443
sw-infrarunbook-01(config-ext-nacl)# no 30
Standard named ACLs work the same way using
ip access-list standard NAME. If you run out of room between sequence numbers,
ip access-list resequence USERS-TO-SERVERS 10 10respaces the whole list starting at 10 in steps of 10.
Step 4: Applying ACLs
For traffic filtering on a Layer 3 interface or SVI, use
ip access-group. For VTY lines, use
access-class. They are different commands and mixing them up is a rite of passage.
sw-infrarunbook-01(config)# interface Vlan10
sw-infrarunbook-01(config-if)# ip access-group USERS-TO-SERVERS in
sw-infrarunbook-01(config)# interface Vlan30
sw-infrarunbook-01(config-if)# ip access-group 130 in
sw-infrarunbook-01(config)# line vty 0 15
sw-infrarunbook-01(config-line)# access-class 10 in
sw-infrarunbook-01(config-line)# transport input ssh
I filter inbound on the SVI because the policy then applies to traffic as it enters the Layer 3 boundary from that VLAN, before routing decisions. That's usually the cleanest model on a campus switch.
Full Configuration Example
Here's the consolidated configuration for sw-infrarunbook-01. I've used named ACLs throughout, plus a standard named list for VTY access. This is the version I'd actually paste into a change window.
hostname sw-infrarunbook-01
!
ip domain-name solvethenetwork.com
username infrarunbook-admin privilege 15 secret <set-a-strong-secret>
!
ip access-list standard MGMT-VTY
remark SSH only from management subnet
10 permit 192.168.99.0 0.0.0.255
20 deny any log
!
ip access-list extended USERS-TO-SERVERS
remark Users VLAN 10 inbound policy
10 permit udp 10.10.10.0 0.0.0.255 host 10.10.20.53 eq 53
20 permit tcp 10.10.10.0 0.0.0.255 host 10.10.20.50 eq 443
30 permit tcp 10.10.10.0 0.0.0.255 host 10.10.20.50 eq 80
40 permit icmp 10.10.10.0 0.0.0.255 10.10.20.0 0.0.0.255 echo
50 deny ip 10.10.10.0 0.0.0.255 10.10.20.0 0.0.0.255 log
60 deny ip 10.10.10.0 0.0.0.255 10.10.30.0 0.0.0.255
70 permit ip 10.10.10.0 0.0.0.255 any
!
ip access-list extended GUEST-POLICY
remark Guest VLAN 30 inbound policy
10 permit udp 10.10.30.0 0.0.0.255 host 10.10.20.53 eq 53
20 permit tcp 10.10.30.0 0.0.0.255 host 10.10.20.50 eq 443
30 deny ip 10.10.30.0 0.0.0.255 10.0.0.0 0.255.255.255 log
40 deny ip 10.10.30.0 0.0.0.255 172.16.0.0 0.15.255.255 log
50 deny ip 10.10.30.0 0.0.0.255 192.168.0.0 0.0.255.255 log
60 permit ip 10.10.30.0 0.0.0.255 any
!
ip access-list extended SERVERS-RETURN
remark Server VLAN 20 inbound - return traffic and updates
10 permit tcp 10.10.20.0 0.0.0.255 10.10.10.0 0.0.0.255 established
20 permit udp host 10.10.20.53 10.10.10.0 0.0.0.255
30 permit icmp 10.10.20.0 0.0.0.255 10.10.10.0 0.0.0.255 echo-reply
40 deny ip 10.10.20.0 0.0.0.255 10.10.30.0 0.0.0.255 log
50 permit ip 10.10.20.0 0.0.0.255 any
!
interface Vlan10
ip address 10.10.10.1 255.255.255.0
ip access-group USERS-TO-SERVERS in
!
interface Vlan20
ip address 10.10.20.1 255.255.255.0
ip access-group SERVERS-RETURN in
!
interface Vlan30
ip address 10.10.30.1 255.255.255.0
ip access-group GUEST-POLICY in
!
interface Vlan99
ip address 192.168.99.2 255.255.255.0
!
line vty 0 15
access-class MGMT-VTY in
transport input ssh
login local
A note on SERVERS-RETURN. Because ACLs are stateless, the
establishedkeyword on line 10 only matches TCP segments with the ACK or RST bit set. It's a crude approximation of a stateful firewall, not the real thing. If you need true session tracking, that's a job for Zone-Based Firewall or a dedicated firewall, not an ACL.
Verification Steps
Don't trust a config because it pasted without errors. Check it. Start by looking at the ACL contents and hit counters:
sw-infrarunbook-01# show ip access-lists USERS-TO-SERVERS
Extended IP access list USERS-TO-SERVERS
10 permit udp 10.10.10.0 0.0.0.255 host 10.10.20.53 eq domain (412 matches)
20 permit tcp 10.10.10.0 0.0.0.255 host 10.10.20.50 eq 443 (1873 matches)
30 permit tcp 10.10.10.0 0.0.0.255 host 10.10.20.50 eq www (27 matches)
40 permit icmp 10.10.10.0 0.0.0.255 10.10.20.0 0.0.0.255 echo (9 matches)
50 deny ip 10.10.10.0 0.0.0.255 10.10.20.0 0.0.0.255 log (3 matches)
60 deny ip 10.10.10.0 0.0.0.255 10.10.30.0 0.0.0.255
70 permit ip 10.10.10.0 0.0.0.255 any (5120 matches)
Those match counts are your best friend. If a permit you expected to be busy shows zero, traffic is either hitting an earlier line or never reaching the interface in that direction. Next, confirm the ACL is actually bound where you think it is:
sw-infrarunbook-01# show ip interface Vlan10 | include access list
Outgoing Common access list is not set
Outgoing access list is not set
Inbound Common access list is not set
Inbound access list is USERS-TO-SERVERS
Then check the VTY restriction. From the admin workstation at 192.168.99.10, SSH should work. From a host in VLAN 10 it should be refused. Confirm on the switch:
sw-infrarunbook-01# show running-config | section line vty
line vty 0 15
access-class MGMT-VTY in
transport input ssh
login local
sw-infrarunbook-01# show ip access-lists MGMT-VTY
Standard IP access list MGMT-VTY
10 permit 192.168.99.0 0.0.0.255 (14 matches)
20 deny any log (2 matches)
To clear counters before a test so the numbers are meaningful, run
clear ip access-list counters USERS-TO-SERVERS. Then generate known traffic and watch only the line you expect to increment. For logged denies,
show logging | include SEC-6-IPACCESSLOGPshows the source, destination and port of what got dropped.
On Catalyst 9000 platforms the ACL is programmed into TCAM. If a large list behaves oddly,
show platform hardware fed switch active fwd-asic resource tcam utilizationtells you whether you've exhausted hardware space. I've seen exactly this on a switch carrying several hundred lines per SVI.
Common Mistakes
Forgetting the implicit deny. You write a tidy list of permits for the traffic you care about, apply it, and ARP-adjacent things like routing protocol hellos or DHCP break. The classic case is applying an inbound ACL to an interface running OSPF or EIGRP without permitting the protocol. Always think about the control-plane traffic crossing that interface.
Getting wildcard masks backwards. Writing
10.10.10.0 255.255.255.0in an ACL is a subnet mask where a wildcard belongs. IOS-XE accepts some of these silently and produces a rule that matches almost nothing. If a line shows zero hits, check the mask first.
Wrong direction. Applying
inwhen you meant
outis the most common error I debug. Say it aloud: "packets arriving on this interface from the VLAN side." For an SVI, inbound means traffic coming from hosts in that VLAN toward the switch.
Ordering specific and general entries wrongly. A broad
permit ip any anyabove a targeted deny makes the deny dead code. With named ACLs,
show ip access-listsexposes it immediately because the later line has no matches ever.
Editing a live ACL carelessly. On a numbered ACL under old habits,
no access-list 130deletes the entire list. If that list is applied to an interface, behaviour on an empty ACL differs by situation, and for a short window you can have either wide-open or locked-down traffic. Use named ACLs, edit by sequence number, and build the replacement list under a new name if the change is big, then swap the
ip access-groupline.
Locking yourself out of the VTY. Applying
access-classbefore confirming your own source address is in the permit list is painful. My habit: add the access-class, keep the current session open, and open a second SSH session from the admin workstation before closing the first. If you do have to recover, use the console. Also consider
reload in 10as a safety net on risky changes, and cancel it with
reload cancelonce you're satisfied.
Assuming ACLs are stateful. They aren't. If you permit outbound TCP 443 from clients but filter the reverse path with a strict list lacking
established, replies die. The reverse also bites:
establishedtrusts anything with the ACK bit set, which an attacker can forge. It's a convenience, not a security boundary.
Missing the logging cost. The
logkeyword punts matching packets to the CPU on many platforms. Slap it on a high-volume deny and you'll push control-plane utilisation up for no good reason. Use it on a handful of lines, and use it for troubleshooting, not as permanent decoration on every entry.
Practical Habits That Save Time
Put a
remarkon every list so the next engineer knows why it exists. Number your named entries in steps of 10. Keep the ACL name descriptive and tied to the interface and direction, something like USERS-TO-SERVERS rather than ACL1. Store the intended configuration in version control and compare it against
show running-config | section ip access-listafter changes. And whenever you change a list that's already bound to an interface, test from the real client segment, not just from the switch.
ACLs are simple until they aren't. Learn the three rules, name your lists, verify with counters, and you'll spend far less time at 2 a.m. wondering why a perfectly reasonable-looking config is dropping traffic.
