Skip to content

CCNA course / Keep the network secure · Step 2 of 13

Guide: Access control listsSwitch

Guide

Access control lists: matching, ordering and placement

Cisco IPv4 access control lists (ACLs) are ordered rules that match packets and either permit or deny them. Learn what each ACL type can match, how rules are evaluated, where to apply them, and how to verify their effect.

7 parts · 12 practice questions

How an IPv4 ACL evaluates traffic

An ACL is a list of permit and deny entries. IOS checks entries in order and stops at the first match. A permit on an interface ACL allows the packet to continue through normal forwarding; a deny drops it. A deny entry does not override or cancel later rules for packets that did not match it.

An ACL definition does not filter forwarded traffic until it is attached to an interface in the intended direction. For router ACLs, inbound traffic is checked as it arrives and outbound traffic after routing as it leaves. Port ACLs filter traffic at the Layer 2 interface in their configured direction. The ip access-group command attaches a numbered or named IPv4 ACL to an interface; in and out specify the direction.

The meaning of permit or deny depends on how the ACL is used. The packet-forwarding behavior described here applies to ACLs used as traffic filters.

IOS XE
interface GigabitEthernet0/1
 ip access-group 10 out
References (1)

Standard and extended ACLs

A standard IPv4 ACL matches the source address only. It cannot distinguish destinations, IP protocols, or transport ports. Use it when the policy is simply to permit or deny traffic from source hosts or networks. For example, a standard ACL permitting host 172.16.1.1 and host 172.16.2.1, with no other permit, allows those sources and denies other sources when used as an interface filter.

Standard ACL match
Source address only
Web destination ports
80 and 443

An extended IPv4 ACL can match source and destination addresses, an IP protocol such as TCP, and protocol details such as TCP or UDP port numbers. Use an extended ACL when the policy depends on a particular destination or service. Cisco examples use TCP destination ports 80 and 443 for web traffic. To block SSH to one server while allowing other IP traffic, use an extended ACL with a TCP destination-port match and a later permit for the remaining traffic.

For two-way subnet isolation with standard ACLs, use a separate source-based ACL for each direction. Each one denies the subnet that must not reach the destination subnet, then permits other sources; apply each outbound toward its protected destination subnet.

IOS XE
access-list 10 permit host 172.16.1.1
access-list 10 permit host 172.16.2.1
ip access-list extended WEB-IN
 permit tcp any host 203.0.113.10 eq 80
 permit tcp any host 203.0.113.10 eq 443
 deny ip any host 203.0.113.10
 permit ip any any
References (1)

Wildcard masks

An IPv4 wildcard mask tells an ACL which address bits to compare. A zero bit must match the corresponding address bit; a one bit is ignored. This is the inverse role of a subnet mask. The wildcard 0.0.0.0 requires an exact address match, while 0.0.0.255 matches any address in the corresponding /24 when paired with its network address.

Exact-match wildcard
0.0.0.0
/24 wildcard
0.0.0.255

The host keyword is shorthand for one exact IPv4 address and its 0.0.0.0 wildcard. The any keyword is shorthand for all IPv4 addresses. For example, host 172.16.1.1 matches only 172.16.1.1; 172.16.2.0 0.0.0.255 matches sources from 172.16.2.0 through 172.16.2.255.

IOS XE
access-list 10 permit 172.16.1.1 0.0.0.0
access-list 10 deny 172.16.2.0 0.0.0.255
References (1)

First match and implicit deny

IOS evaluates ACL entries from top to bottom. The first matching entry decides the result, and later entries are not considered for that packet. Put specific exceptions before broader rules. For example, deny 172.16.2.0 0.0.0.255 followed by permit any blocks sources in 172.16.2.0/24 and permits all other sources in a standard ACL.

First match wins: walk an ACL

TCP → 10.0.0.10:22Deny SSH (TCP 22) to 10.0.0.10deny tcp any host 10.0.0.10 eq 22Permit TCP to 10.0.0.10permit tcp any host 10.0.0.10Deny all unmatched trafficimplicit deny ip any anyPNo match yet; keep checking

Follow this SSH packet. The ACL checks rules from top to bottom.

Selected packet: SSH (TCP 22). Outcome with this order: deny.

Step 1 of 4

Choose a packet and an entry order

This example is an inbound extended ACL used as an interface traffic filter. Follow the selected packet through the entries. A matching entry ends the decision.

More detail for this step
Read the example before pressing play
  • ACL means access control list: an ordered set of matching rules. This ACL is attached inbound as a traffic filter.
  • The server is 10.0.0.10. The examples use SSH on TCP 22, HTTPS on TCP 443 and DNS on UDP 53.
  • With the broad permit first switch off, the specific SSH deny is checked before the rule permitting TCP to the server.

Read the caption, follow the highlighted action, then see its result. Pause or step through at your own pace.

Every filtering ACL has an implicit deny any at the end. A packet that matches no explicit permit is dropped, even when no explicit deny was entered. A deny-only interface ACL therefore drops all packets. Add a final permit only when the intended policy allows remaining traffic; permit ip any any permits all remaining IP traffic. An explicit deny can make denied traffic visible in counters or logs, but is not required for the deny behavior.

The meaning of permit or deny depends on the context in which an ACL is used, so do not assume every ACL reference is a packet filter.

IOS XE
access-list 10 deny 172.16.2.0 0.0.0.255
access-list 10 permit any
References (1)

ACL placement and direction

A standard ACL matches only the source address, while an extended ACL can also match destination addresses and protocol information. Choose the interface and direction based on where the traffic should be filtered; Cisco's Catalyst example applies a standard ACL outbound on the routed port leading to the protected server. Since a standard ACL cannot distinguish destinations, applying it near the protected destination can limit its effect on that traffic; this placement rationale follows from the matching behavior, while the Cisco example demonstrates one specific topology.

Choose in for packets entering an interface and out for packets leaving it. An outbound ACL on the router interface leading to a protected subnet filters forwarded packets as they exit toward that subnet. Creating an ACL alone does not attach it to the forwarding path. If unauthorized traffic still passes and show ip interface reports no outbound ACL, apply the intended ACL in the outbound direction on that interface.

For two standard source-based restrictions between two subnets, configure separate ACLs and apply each outbound toward the destination subnet it protects. Permit the other sources after the targeted deny when those sources should continue to reach that subnet.

IOS XE
interface GigabitEthernet0/1
 ip access-group ONE out
References (1)

Named ACLs and entry order

A named ACL uses ip access-list standard NAME or ip access-list extended NAME to enter ACL configuration mode. Named ACLs may be standard or extended. Like numbered ACLs, they are evaluated in order and use the same matching and implicit-deny rules.

Unnumbered entry increment
10 greater than the last sequence number
Permit sequence example
90 before deny at 100

For named standard and extended ACLs, an entry without a sequence number is assigned a number 10 greater than the last sequence number and placed at the end. If a named ACL ends at sequence 100 with deny ip any any, an unnumbered permit is appended after it and cannot match. Give the permit a lower sequence number, such as 90, to place it before the deny.

IOS XE
ip access-list extended WEB-IN
 90 permit tcp any host 203.0.113.10 eq 80
 100 deny ip any any log
References (1)

Verify ACL attachment, order, and matches

Use show access-lists or show ip access-lists to display ACL entries and software match counts. On Catalyst 9300, the show ip access-lists match count omits packets processed in hardware, so use show platform software fed switch {switch_num | active | standby} acl counters hardware for basic hardware statistics. Do not treat logging output as an exact match counter: Cisco cautions that logging may omit packets at high rates. The displayed entries follow sequence order, which may differ from the order in which commands were entered.

Use show ip interface to check which IPv4 ACL is attached to an interface and whether it is inbound or outbound. If traffic bypasses a policy, confirm the ACL is attached to the correct interface and direction, then inspect rule order and counters. If an authorized source is unexpectedly blocked, look for an earlier matching deny or the implicit deny at the end.

IOS XE
show access-lists
show ip interface GigabitEthernet0/1
References (2)

Check your understanding

Access control lists: matching, ordering and placement

All 7 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.