CCNA IPv4 ACLs: Standard, Extended, Numbered and Named Access Lists
<p>An IPv4 access control list (ACL) is an ordered list of permit and deny statements that a Cisco router checks, top-down and first-match, against each packet's IPv4 header to decide whether to forward or drop it. This lesson covers the CCNA 200-301 v2.0 exam topic on configuring IPv4 ACLs: standard and extended ACLs, numbered and named forms, wildcard masks, processing order and the implicit deny, placement, applying ACLs inbound or outbound, protocol and port matching, the <code>established</code> keyword, sequence-number editing, vty access with <code>access-class</code>, the effect on routing protocols and router-originated traffic, and verification.</p>
On this page10 sections
- What is an IPv4 ACL and how does a router process it?
- Standard vs extended ACLs: what can each match?
- Wildcard masks: how does an ACL entry match a range of addresses?
- Where should a standard or extended ACL be placed?
- How do you apply an ACL to an interface, and in which direction?
- How do you write extended ACL entries for protocols and ports?
- Are ACLs stateful, and what does the established keyword do?
- How do you edit named ACLs with sequence numbers?
- How do you restrict SSH and Telnet to the router with access-class?
- How do you verify and troubleshoot ACLs?
- Explain top-down, first-match processing, shadowed entries and the implicit deny at the end of every ACL
- Choose between standard and extended ACLs and identify their numbered ranges and named-ACL syntax
- Calculate wildcard masks for hosts, subnets and summaries, and read non-contiguous wildcards
- Place and apply ACLs with ip access-group in or out, and predict which traffic each direction filters
- Write extended entries that match the right protocol, port position, ICMP type and the established keyword
- Insert, delete and resequence entries in named ACLs, and restrict vty access with access-class
- Verify ACLs with show access-lists and show ip interface, including logging the implicit deny
What is an IPv4 ACL and how does a router process it?
An IPv4 access control list is an ordered list of permit and deny entries (access control entries, ACEs) that a router compares against a packet's header fields. Once applied to an interface in a direction, it decides whether each packet crossing that interface is forwarded or dropped. ACLs are also used to select traffic for other features (vty access, NAT, QoS, route filtering); this lesson covers their use as packet filters and on vty lines.
Processing follows three rules, and almost every troubleshooting question comes down to one of them:
- Top-down. Entries are checked in sequence-number order, starting with the lowest. (In standard ACLs IOS may store and display single-host entries ahead of range entries for speed, but it only does so where the first-match result cannot change.)
- First match wins. As soon as a packet matches an entry, that entry's action (permit or deny) is taken and no further entries are checked. A broad entry placed above a specific one shadows it: the specific entry can never be reached for the packets the broad one already matched.
- Implicit deny. Every ACL ends with an invisible
deny any(standard) ordeny ip any any(extended). A packet that matches no entry is dropped. An ACL that contains only deny entries therefore blocks everything; it needs at least one permit, usually a finalpermit anyorpermit ip any any.
Example: in an ACL whose entry 10 is permit ip 172.20.0.0 0.0.255.255 any and entry 20 is deny tcp host 172.20.7.40 any eq 3389, a Remote Desktop packet from 172.20.7.40 matches entry 10 first and is permitted. Entry 20 never fires. The fix is ordering: a specific exception must sit above the broad rule it is an exception to.
ACLs are stateless: each packet is judged on its own headers, with no memory of the connection it belongs to. That is why return traffic needs its own thought (see the section on established).
Standard vs extended ACLs: what can each match?
A standard ACL matches only the packet's source IPv4 address. An extended ACL matches the protocol, the source and destination addresses, and for TCP and UDP the source and destination ports (plus options such as ICMP message types and the established keyword). If a requirement mentions a destination, an application or a port, only an extended ACL can express it.
| Standard ACL | Extended ACL | |
|---|---|---|
| Matches on | Source address only | Protocol, source, destination, ports, ICMP type, TCP flags |
| Numbered ranges | 1–99 and 1300–1999 | 100–199 and 2000–2699 |
| Named form | ip access-list standard NAME | ip access-list extended NAME |
| Entry example | deny 192.168.40.0 0.0.0.255 | deny udp 192.168.40.0 0.0.0.255 host 192.168.90.5 eq 69 |
| Usual placement | Close to the destination | Close to the source |
The number tells IOS which type a numbered ACL is: access-list 50 and access-list 1999 are standard, access-list 101 and access-list 2699 are extended. Numbers outside the four ranges belong to other protocols or are not valid IPv4 ACL numbers. Names carry no such meaning, so a named ACL declares its type in the ip access-list standard or ip access-list extended command.
The syntax differs accordingly. A standard entry has no protocol field and no destination: permit any, deny host 192.168.40.9, deny 192.168.40.0 0.0.0.255. An entry that names a protocol and a destination is extended syntax: typed in ip access-list standard mode, IOS rejects it.
Wildcard masks: how does an ACL entry match a range of addresses?
A wildcard mask tells the router which bits of the address to check: a 0 bit means "must match" and a 1 bit means "ignore". It is not a subnet mask. For a contiguous block, the wildcard is the inverse of the subnet mask: subtract each octet of the mask from 255.
| Prefix | Subnet mask | Wildcard | Example entry |
|---|---|---|---|
| /32 (one host) | 255.255.255.255 | 0.0.0.0 | 192.168.7.9 0.0.0.0 = host 192.168.7.9 |
| /24 | 255.255.255.0 | 0.0.0.255 | 192.168.30.0 0.0.0.255 |
| /21 | 255.255.248.0 | 0.0.7.255 | 10.16.56.0 0.0.7.255 (10.16.56.0–10.16.63.255) |
| /16 | 255.255.0.0 | 0.0.255.255 | 172.20.0.0 0.0.255.255 |
| All addresses | — | 255.255.255.255 | 0.0.0.0 255.255.255.255 = any |
Two shorthands replace the common cases: host A.B.C.D equals the address with wildcard 0.0.0.0, and any equals 0.0.0.0 255.255.255.255. They are interchangeable in both standard and extended entries.
Common errors that IOS accepts without complaint:
- A subnet mask typed as a wildcard.
192.168.7.9 255.255.255.255ignores every bit and matches any address;192.168.40.0 255.255.255.0checks only the last octet. IOS reads the second value as a wildcard whatever it looks like. - The wrong block size. The wildcard for a prefix is the block size minus one in the interesting octet. A /21 has a third-octet block of 8, so its wildcard is 0.0.7.255; 0.0.15.255 would cover a /20 (twice the range) and 0.0.8.255 is not a contiguous block at all. The base address must also sit on a block boundary (a multiple of 8 here).
- A host address with a network wildcard.
permit 192.168.30.45 0.0.0.255matches all of 192.168.30.0–192.168.30.255. IOS normalises the entry by zeroing the ignored bits, soshow access-listsdisplayspermit 192.168.30.0, wildcard bits 0.0.0.255. The display reveals what the entry really matches.
Non-contiguous wildcards are legal because each bit is evaluated independently. Read them octet by octet: a 0 octet must match, a 255 octet is ignored. If every branch numbers its management loopback 172.<region>.<branch>.1 inside 172.16.0.0/12, the entry 172.16.0.1 0.15.255.0 fixes the last octet at .1 and ignores the region and branch values, matching the loopback of every branch with one line. A wildcard can also pick alternate blocks: 10.8.1.0 0.0.254.255 ignores every third-octet bit except the lowest, so it matches only the odd-numbered /24s in 10.8.0.0/16. Such entries match exactly what the bits say, so check them against the addressing plan.
Where should a standard or extended ACL be placed?
The classic guideline is: put a standard ACL as close to the destination as possible, and an extended ACL as close to the source as possible. Both follow from what the ACL can see.
- A standard ACL matches only the source. Placed near the source,
deny 192.168.40.0 0.0.0.255would stop that subnet from reaching everything, not just the protected destination. Placed outbound on the interface facing the protected LAN, it affects only traffic heading there. - An extended ACL can name the destination and application, so it can drop unwanted packets at the first router they reach. Placing it inbound on the source's LAN interface stops the packets before they consume WAN bandwidth and router CPU along the path.
The guideline gives way to real constraints. A standard ACL near the source cannot block one destination while allowing others, because it never looks at the destination. So when the only router you may change sits on the source side, the job needs an extended ACL there that names the destination. And when a requirement is about protecting the path itself (bandwidth, CPU on routers in between), only filtering where the traffic enters the network meets it, whatever ACL type is used.
How do you apply an ACL to an interface, and in which direction?
An ACL does nothing until it is applied. On an interface the command is ip access-group {number | name} {in | out}, entered in interface configuration mode.
- in filters packets as they arrive on the interface, before the router makes a routing decision.
- out filters packets the router is forwarding out of that interface, after routing.
Think from the router's point of view: traffic from a user LAN arrives in on the LAN interface, while traffic toward that LAN leaves out of it.
Rules that decide many questions:
- One IPv4 ACL per interface per direction. Entering a second
ip access-group … inon the same interface silently replaces the first; IOS does not merge or chain them. To filter both SNMP and TFTP in one direction, put both entries in one ACL. - Outbound ACLs do not filter traffic the router itself originates (a ping or SSH session typed on the router's CLI, routing updates it sends). Transit traffic is filtered; locally generated packets bypass the outbound check.
- Inbound ACLs do filter traffic addressed to the router, which leads to the control-plane surprises covered below.
- An applied ACL that does not exist filters nothing. ACL names are case-sensitive.
ip access-group Mgmt-Filter inwhen the configured ACL isMGMT-FILTERis accepted without error and shows up inshow ip interface, but because Mgmt-Filter is undefined, IOS permits all traffic on that interface. The same happens if you delete an ACL that is still bound.
access-class is a different command used only on vty lines, and ipv6 traffic-filter applies IPv6 ACLs; neither applies an IPv4 ACL to an interface.
Why can an inbound ACL break routing protocols and the router's own pings?
An inbound ACL checks every packet arriving on the interface, including packets addressed to the router itself. When an ACL ends in a deny, any control-plane traffic not explicitly permitted is dropped:
- Routing protocols. OSPF hellos are sent to the multicast address 224.0.0.5 using IP protocol 89. An inbound ACL that permits only user traffic drops them, and the adjacency goes down once the dead interval expires. The permit must use the
ospfprotocol keyword (OSPF runs directly over IP, so no TCP or UDP entry can match it), take the neighbour as the source, and use a destination that covers the multicast group, such asanyorhost 224.0.0.5; for examplepermit ospf host 172.31.5.2 anyon a link where the neighbour is 172.31.5.2. A destination of only the router's own interface address misses hellos sent to 224.0.0.5. Place it above the final deny. - Replies to the router's own traffic. A ping typed on R1 leaves without an outbound check, but the
echo-replyfrom the neighbour arrives inbound and is dropped by an inbound ACL that does not permit it. The narrow fix permits only ICMP echo-replies from the neighbour to the router's link address, for examplepermit icmp host 172.31.5.2 host 172.31.5.1 echo-replywhen the router is 172.31.5.1: source = the neighbour, destination = the router, message type = reply.
Before applying a restrictive inbound ACL on a routed link, list what the router itself needs to receive there: routing-protocol packets, replies to its own pings and management sessions, and any management traffic such as SSH to the router.
How do you write extended ACL entries for protocols and ports?
An extended entry follows a fixed order: action, protocol, source, [source port], destination, [destination port], [options].
access-list 130 deny tcp 192.168.40.0 0.0.0.255 host 192.168.90.20 eq 80
Here tcp is the protocol, 192.168.40.0 0.0.0.255 the source, host 192.168.90.20 the destination and eq 80 the destination port.
A port operator belongs to whichever address it follows. eq 80 after the destination matches destination port 80 (an HTTP request to the server). The same eq 80 written after the source matches source port 80, which a browser opening a connection never uses. Requests from clients to servers almost always match on the destination port; the client's source port is a random high port.
Key elements:
- Protocol keywords:
ip(any IPv4 packet),tcp,udp,icmp, and routing protocols such asospf(IP protocol 89) andeigrp(88). Ports exist only fortcpandudp; OSPF and ICMP have none, so "tcp … eq 89" does not match OSPF. - Port operators:
eq(equal),neq,gt(greater than),lt(less than) andrange low high.gt 21matches 22 and every higher port, so it is not an exact match for SSH;eqis the only operator that matches one port. - Port names: IOS accepts names such as
www(80),telnet(23),domain(53) andftp(21), and may display them inshowoutput instead of the number. - Match TCP vs UDP correctly. DNS lookups use UDP 53 (TCP 53 is used for large responses and zone transfers), so an ACL permitting only
tcp … eq 53breaks name resolution. SSH is TCP 22, Telnet TCP 23, HTTP TCP 80, HTTPS TCP 443, TFTP UDP 69, SNMP UDP 161, NTP UDP 123. - ICMP types:
echois a ping request andecho-replyits answer, e.g.permit icmp any any echo-reply.
Choosing the narrowest entry means narrowing every field the requirement names: the protocol (tcp or udp, not ip), the destination (host, or the address with wildcard 0.0.0.0, when one server is meant), and the port (eq). For "SSH from the admin /28 to one jump host only": permit tcp 172.20.250.0 0.0.0.15 host 192.168.90.22 eq 22. Widening any one field matches more than the requirement allows.
Evaluating a packet against an extended ACL means checking every field of each entry in order. A packet from 172.20.6.9 to UDP 161 matches deny udp 172.20.0.0 0.0.255.255 any eq snmp even if a later entry permits 172.20.6.0/23 to the same port: the earlier entry is broader and wins. A packet whose protocol appears in no entry (for example GRE in an ACL of only TCP and UDP entries) falls to the implicit deny.
Are ACLs stateful, and what does the established keyword do?
No. IOS ACLs are stateless, so an inbound ACL on an internet-facing interface also judges the replies to connections your users opened. If an inbound ACL on the internet link of a publicly addressed LAN 203.0.113.0/24 permits only tcp any host 203.0.113.25 eq 25 (an inbound mail server), the users' outbound web sessions break: the replies come from the web servers' ports to the users' high ports and hit the implicit deny.
The established keyword on a TCP entry matches segments that have the ACK or RST bit set. Every segment of an open TCP session except the very first SYN carries ACK, so
permit tcp any 203.0.113.0 0.0.0.255 established
lets return traffic reach the users while a new inbound connection attempt (a bare SYN) still falls through to the deny. It is a flag check, not a state table: the router does not track sessions, and a crafted packet with ACK set would also match. Real session tracking needs a stateful firewall feature, which is beyond this topic. established applies only to TCP; UDP replies (such as DNS answers) need their own entries.
An entry that permits a server port toward the users' range is not the same thing: a port match ignores the flags, so it admits brand-new connections to that port on every user host.
How do you edit named ACLs with sequence numbers?
Every entry in an IOS ACL has a sequence number, shown by show access-lists. By default, entries are numbered 10, 20, 30…, and an entry entered without a sequence number is appended at the end (the last number plus 10), which places it after any final deny ip any any where it can never match.
In ACL configuration mode (ip access-list extended CORE-FILTER, which also works for numbered ACLs, e.g. ip access-list extended 140):
- Insert an entry by giving it a number between two existing ones:
35 deny udp host 172.20.7.40 any eq 69lands between 30 and 40 and is evaluated before 40. - Delete a single entry with
no <seq>, e.g.no 40. The rest of the ACL and its interface binding stay in place. - Resequence when there is no free number between two entries:
ip access-list resequence CORE-FILTER 100 10(global mode; the arguments are the starting number and the increment) renumbers the entries 100, 110, 120… in their existing order, opening gaps for new inserts. Entries keep their order; only their numbers change.
A worked case: entries 31, 32, 33 and 34 leave no number between 32 and 33. After resequencing with start 100 and increment 10, they become 100, 110, 120 and 130, so an entry that must run before old entry 33 (now 120) is added as 115.
Two destructive commands to avoid when only one line must change: no ip access-list extended CORE-FILTER deletes the whole ACL (the interface then references an undefined ACL and permits everything), and in global mode no access-list 140 … on a numbered ACL removes the entire ACL 140, not just the matching line. no ip access-group unbinds the ACL from the interface but leaves it defined.
How do you restrict SSH and Telnet to the router with access-class?
To control who can open a management session to the router itself, apply a standard (or extended) ACL to the vty lines with access-class <acl> in:
access-list 8 permit 172.20.250.0 0.0.0.15
line vty 0 15
access-class 8 in
transport input ssh
This restricts sessions arriving on any interface, because it is checked when a session reaches a vty line, and it does not affect transit traffic routed through the router. Applying ip access-group on every interface instead would also filter user traffic passing through.
access-class … infilters incoming vty sessions by source address.access-class … outfilters the sessions a user on the router opens from it to other devices; it does not protect the router.- The class must be on every vty line. Routers usually have lines 0–15, and the running configuration often shows them as two blocks,
line vty 0 4andline vty 5 15, each with its own settings. IOS assigns an incoming session to the lowest free line, so if only the first block carries the access-class, the filter holds only while a free line remains in that block; once those lines are busy, the next session lands on an unfiltered line. Editing the ACL cannot close that gap, because a line without an access-class never consults the ACL. - The implicit deny applies here too: everything not permitted by ACL 8 is refused.
How do you verify and troubleshoot ACLs?
Three commands answer the three questions you always ask: what does the ACL say, is it matching, and where is it applied?
| Command | What it shows |
|---|---|
show access-lists / show ip access-lists [name] | Every entry with its sequence number and a per-entry match counter, e.g. 20 permit udp any host 192.168.90.53 eq domain (342 matches). Also reveals normalised addresses. |
show ip interface <interface> | Which ACL is bound and in which direction: Outgoing access list is … / Inbound access list is …. |
show running-config | The configured entries and ip access-group lines, but no counters. |
Reading the evidence:
- The implicit deny has no counter. To count and log dropped packets, add an explicit final entry such as
90 deny ip any any log. It drops exactly what the implicit deny dropped, so the ACL's behaviour is unchanged, but now drops are counted and logged. The action matters as much as thelogkeyword: a final permit would change what the ACL allows. - Zero matches on every entry usually means the ACL is not where the traffic is: bound in the wrong direction, on the wrong interface, or not bound at all. Read the direction lines of
show ip interfaceagainst the requirement: an ACL meant for traffic from a LAN must appear as the inbound list on that LAN's interface. If it shows as the outgoing list there, it is checking traffic routed toward the LAN, and packets arriving from the LAN pass unfiltered. - An ACL bound but no traffic filtered at all can mean the bound name does not match a defined ACL (names are case-sensitive).
clear access-list counters [name]resets the counters so a fresh test shows only new matches. It changes nothing about filtering.
Tip. Questions on this topic are mostly scenarios with evidence in the stem: ACL entries, show access-lists output with counters, or show ip interface output. You are asked which entry or wildcard matches a stated range, which packets an ACL permits, why an ACL blocks or allows more than intended (entry order, the implicit deny, a mask typed as a wildcard, the wrong direction, a mistyped name), where to place and how to apply an ACL under constraints such as which routers you may change or which links must be spared, how to insert, delete or resequence an entry without removing the ACL, how to restrict vty access, and why a routing adjacency or the router's own ping fails after an inbound ACL is applied. Some items ask you to select two answers.
- ACLs are checked top-down and the first matching entry decides; a broad entry above a specific one shadows it.
- Every ACL ends with an implicit deny, so a list of only deny entries blocks all traffic.
- Standard ACLs (1–99, 1300–1999) match only the source address; extended ACLs (100–199, 2000–2699) match protocol, source, destination and ports.
- A wildcard 0 bit must match and a 1 bit is ignored; host = 0.0.0.0 and any = 255.255.255.255, and IOS zeroes ignored address bits when it stores an entry.
- Standard ACLs go near the destination and extended ACLs near the source, unless the scenario's constraints dictate otherwise.
- One ACL per interface per direction; a second ip access-group in the same direction replaces the first.
- Outbound ACLs do not filter router-originated traffic, but inbound ACLs do filter routing-protocol packets and replies addressed to the router.
- A port operator applies to the address it follows; client requests normally match the destination port.
- ACLs are stateless; established matches TCP segments with ACK or RST set, letting replies in while blocking new inbound connections.
- Use sequence numbers to insert an entry between two others, delete one entry with no <seq> and resequence a crowded list, all without removing the ACL from the interface; apply vty filters with access-class in on every vty line.
Frequently asked questions
What is the difference between a standard and an extended ACL?
A standard IPv4 ACL matches only a packet's source address and uses numbers 1–99 or 1300–1999. An extended ACL matches the protocol, source and destination addresses, TCP or UDP ports and other options, and uses numbers 100–199 or 2000–2699. Named ACLs declare their type with ip access-list standard or ip access-list extended.
How do I calculate a wildcard mask for an ACL?
For a contiguous subnet, subtract each octet of the subnet mask from 255. A /24 (255.255.255.0) becomes 0.0.0.255, a /21 (255.255.248.0) becomes 0.0.7.255 and a /27 (255.255.255.224) becomes 0.0.0.31. In the wildcard, 0 bits must match and 1 bits are ignored; host means 0.0.0.0 and any means 255.255.255.255.
What is the implicit deny in a Cisco ACL?
Every Cisco ACL ends with an invisible deny for all traffic, so any packet that matches no entry is dropped. It does not appear in show access-lists and has no counter; adding an explicit deny ip any any log as the last entry makes those drops visible without changing what the ACL permits.
Where should standard and extended ACLs be placed?
A standard ACL is placed close to the destination, because it can only match the source and would block that source from everything if placed near it. An extended ACL is placed close to the source, so unwanted packets are dropped before crossing the network. Real constraints, such as which routers you are allowed to change, can override the guideline.
Can an interface have more than one ACL?
An interface can have one IPv4 ACL inbound and one outbound. Entering a second ip access-group command in the same direction replaces the existing ACL rather than adding to it, so all the filtering for that direction must be in a single ACL.
Does an outbound ACL filter traffic the router sends itself?
No. An outbound IPv4 ACL filters packets the router forwards, not packets it originates, such as a ping typed on its CLI. Inbound ACLs do check packets addressed to the router, so they can drop routing-protocol hellos and the replies to the router's own pings unless those are permitted.
What does the established keyword match in an extended ACL?
The established keyword matches TCP segments that have the ACK or RST bit set, which is every segment of an existing TCP session except the first SYN. It lets return traffic for connections opened from inside pass an inbound ACL while new inbound connection attempts are still denied. It checks flags only; it does not track session state.
How do I restrict SSH access to a Cisco router to one subnet?
Create an ACL that permits the management subnet, then apply it to all vty lines with access-class <acl> in under line vty 0 15. This filters management sessions arriving on any interface without affecting traffic routed through the router. Every vty line needs it, or sessions that land on an unfiltered line bypass the restriction.
Source
This lesson covers the "Network Services and Security" domain of the official CCNA exam guide. Vendors revise their guides — check the source for the current version.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.