Routelearn.net
Course menu

Course 13: Security FundamentalsLesson 3.2 (7 of 8 in this course)85 of 91 in the CCNA series

Extended and named ACLs

Matching protocols and ports with extended ACLs, named ACLs, editing with sequence numbers, and placement.

Intermediate · 13 min read

An extended ACL (access control list) is an ACL whose entries can match a packet’s protocol, source and destination addresses, and TCP or UDP port numbers. Because it can single out specific traffic, it is normally applied close to the source of that traffic.

In simple terms: A standard ACL only asks “who sent this?” An extended ACL can also ask where the packet is going and which application it is for, such as web or SSH.

A real-life situation

In Standard ACLs you blocked the Sales LAN from the whole server LAN. A week later the rule changes: Sales now needs the company web app on SRV1, which runs on HTTPS (TCP port 443). They should also be able to ping it. Every other kind of traffic from Sales to the server LAN, such as file sharing, must stay blocked.

A standard ACL can't do this. It only sees the source address, so it can block Sales from everything or nothing. You need a rule that says who, to where and what kind of traffic. That is an extended ACL.

Gi0/0192.168.10.0/24Gi0/2192.168.20.0/24Gi0/1Gi0/110.0.12.0/30Gi0/0PC1 (Sales)192.168.10.10Admin PC192.168.20.10R1R2SRV1 (web)192.168.30.10/24
  1. 1. HTTPS to SRV1: permitted. The packet enters R1 Gi0/0. Entry 10 (TCP from Sales to host 192.168.30.10, destination port 443) matches, so R1 routes it on.
  2. 2. File sharing to SRV1: denied at R1. Entries 10 and 20 don't match port 445. Entry 30 denies anything else from Sales to 192.168.30.0/24. The packet is dropped at the first router, before it uses the R1-R2 link.
  3. 3. Sales to the Admin LAN: permitted. Nothing above matches, so entry 40 (permit ip any any) lets it through. Placing the ACL near the source didn't cut Sales off from other networks.
  4. 4. Admin traffic: never checked. It arrives on R1 Gi0/2, which has no ACL. The Sales ACL only filters packets entering Gi0/0.

What an extended ACL is

An extended ACL follows the same basic rules as a standard one: entries are checked top-down, the first match wins, and an invisible deny any ends the list. The difference is how much of the packet each entry can look at:

  • the protocol (ip, tcp, udp, icmp, ospf and others),
  • the source address and wildcard,
  • the destination address and wildcard,
  • for TCP and UDP, the source and destination ports,
  • a few extras, such as the ICMP message type or log.
Version4 bits
IHL4 bits
DSCP / ECN8 bits
Total length16 bits
Identification16 bits
Flags3 bits
Fragment offset13 bits
TTL8 bits
Protocol8 bits6 = TCP, 17 = UDP
Header checksum16 bits
Source address32 bitsthe only field a standard ACL checks
Destination address32 bits
TCP/UDP source port16 bits
TCP/UDP destination port16 bits
The IPv4 header plus the start of the TCP or UDP header. Highlighted: the fields an extended ACL can match.

If ports are new to you, see Port numbers and sockets and Common ports to know.

Numbered or named

Extended ACLs can be numbered (100-199 and 2000-2699) or named. A named ACL uses a word you choose, like SALES-IN, so anyone reading the configuration can tell what it is for. Named ACLs also make editing easy, because you work inside the list and can address each line by its sequence number. Standard ACLs can be named too; the name just goes with ip access-list standard.

Why it works that way

Place extended ACLs close to the source. An extended entry names both the source and the destination, so it can sit right next to the source without blocking anything else. Dropping unwanted packets at the first router also means they never waste bandwidth on the links behind it. Compare this with a standard ACL, which goes close to the destination because it can't see where a packet is going.

ACLs are stateless. The router checks every packet on its own and keeps no memory of connections. When SRV1 replies to PC1, the reply is a brand-new packet: source 192.168.30.10, source port 443, destination 192.168.10.10. An ACL on the return path must permit it too. This ACL is inbound on the Sales side, so the replies (which leave R1 through Gi0/0) are never checked by it. Placing it this way keeps the rules simple.

How it works step by step

Every extended entry follows the same pattern. The order of the parts matters: a port written after the source applies to the source port, and a port written after the destination applies to the destination port.

[seq] permit|deny <protocol> <source> <wildcard> [port] <destination> <wildcard> [port] [options]

The general form inside a named list. In the numbered form the line starts with access-list 100-199 instead of a sequence number.

PartExampleMeaning
ActionpermitLet matching packets through (or deny to drop them)
Protocoltcpip means any IPv4 packet; tcp, udp, icmp narrow it
Source192.168.10.0 0.0.0.255Any host in the Sales LAN
Destinationhost 192.168.30.10Only SRV1
Port operatoreq 443Destination port equals 443. Others: neq, lt, gt, range 20 21
OptionlogSend a log message when the entry matches (rate-limited)

Now follow one packet from PC1 to SRV1 on TCP port 445 through this list:

10 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 443 20 permit icmp 192.168.10.0 0.0.0.255 host 192.168.30.10 echo 30 deny ip 192.168.10.0 0.0.0.255 192.168.30.0 0.0.0.255 log 40 permit ip any any (implicit) deny ip any any

The SALES-IN list as R1 evaluates it.

  1. Entry 10: protocol TCP, yes. Source in 192.168.10.0/24, yes. Destination 192.168.30.10, yes. Destination port 443? No, it is 445. No match, keep going.
  2. Entry 20: protocol ICMP? No, it's TCP. No match.
  3. Entry 30: protocol ip covers TCP. Source and destination networks match. The action is deny, so R1 drops the packet, writes a log message and stops checking.

A ping from PC1 to SRV1 matches entry 20 (echo is the ICMP echo request). A web request to a server on another network would pass entries 10 to 30 without a match and be permitted by entry 40.

How to configure it on Cisco IOS

⚠️ Based on Cisco IOS / IOS XE documentation, not run on a lab device.

Named extended ACL

ip access-list extended SALES-IN remark Sales: HTTPS and ping to SRV1 only, nothing else to the server LAN 10 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 443 20 permit icmp 192.168.10.0 0.0.0.255 host 192.168.30.10 echo 30 deny ip 192.168.10.0 0.0.0.255 192.168.30.0 0.0.0.255 log 40 permit ip any any ! interface GigabitEthernet0/0 ip access-group SALES-IN in

On R1. Sequence numbers are optional; if you leave them out, IOS numbers the entries 10, 20, 30 and so on.

The same list, numbered

access-list 110 remark Sales: HTTPS and ping to SRV1 only access-list 110 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 443 access-list 110 permit icmp 192.168.10.0 0.0.0.255 host 192.168.30.10 echo access-list 110 deny ip 192.168.10.0 0.0.0.255 192.168.30.0 0.0.0.255 log access-list 110 permit ip any any ! interface GigabitEthernet0/0 ip access-group 110 in

Each global access-list line is appended to the end of list 110.

Editing with sequence numbers

Another week, another change: the web app also needs plain HTTP (TCP 80) so it can redirect browsers to HTTPS, and management has decided that ping is no longer needed. Inside the named list you can insert a line between two others and delete a single line:

ip access-list extended SALES-IN 15 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 80 no 20

15 lands between 10 and 30. no 20 removes only that entry. The rest of the list is untouched.

ip access-list resequence SALES-IN 10 10

Optional: renumber the entries to 10, 20, 30 ... so there is room to insert lines again.

This also works for numbered lists: enter ip access-list extended 110 and edit by sequence number in the same way. That is much safer than the global no access-list 110 ..., which deletes the entire list.

A full example for R1

interface GigabitEthernet0/0 description Sales LAN ip address 192.168.10.1 255.255.255.0 ip access-group SALES-IN in ! interface GigabitEthernet0/1 description Link to R2 ip address 10.0.12.1 255.255.255.252 ! interface GigabitEthernet0/2 description Admin LAN ip address 192.168.20.1 255.255.255.0 ! ip access-list extended SALES-IN remark Sales: web to SRV1 only, nothing else to the server LAN 10 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 443 15 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 80 30 deny ip 192.168.10.0 0.0.0.255 192.168.30.0 0.0.0.255 log 40 permit ip any any

R1 after the edit. The ACL sits inbound on the interface closest to the source.

How to verify it

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip access-lists SALES-IN
Extended IP access list SALES-IN
    10 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 443 (214 matches)
    15 permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq www (9 matches)
    30 deny ip 192.168.10.0 0.0.0.255 192.168.30.0 0.0.0.255 log (6 matches)
    40 permit ip any any (1032 matches)
IOS shows some well-known ports by name, so port 80 appears as www. The counters show the policy at work: entry 30 is catching other traffic to the server LAN. Remarks are not shown here; you see them in the running configuration.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip interface GigabitEthernet0/0
GigabitEthernet0/0 is up, line protocol is up
  Internet address is 192.168.10.1/24
  ...
  Outgoing access list is not set
  Inbound  access list is SALES-IN
  ...
The list is applied to traffic arriving from the Sales LAN.

Then test from both sides of the rule. From PC1, the web app should load and a file share on SRV1 should fail. If you watch the console or the log buffer (show logging), each denied packet that hits entry 30 produces a log message naming the list, the source and the destination. IOS rate-limits these messages, so you won't see one for every single packet.

What goes wrong and how to troubleshoot it

SymptomLikely causeCheck / fix
The permitted web app doesn't workPort written after the source (matches the source port, which is random)Put eq 443 after the destination
Replies never come backAn ACL on the return path doesn't permit the reply packetsRemember ACLs are stateless; permit the replies or move the ACL
A routing neighbour goes down after applying the ACLThe implicit deny drops OSPF hellos arriving on that interfaceAdd permit ospf any any (or the routing protocol you use) above the deny
Users get no DNS, but IP addresses workThe list permits TCP 443 to the internet but not DNS (UDP 53)Add permit udp ... eq 53 to the DNS server
An entry never matchesAn earlier, broader entry already matches those packetsshow ip access-lists: compare the counters; reorder with sequence numbers

When in doubt, work through the list by hand for one packet: write down its protocol, source, destination and ports, then compare with each entry from the top. That's exactly what the router does.

Common mistakes

  • Port on the wrong side. permit tcp 192.168.10.0 0.0.0.255 eq 443 host 192.168.30.10 matches packets from port 443, not packets to it.
  • Using ip with a port. Ports only exist for tcp and udp entries.
  • Forgetting permit ip any any when the policy is "block only this". Without it, the implicit deny blocks everything else.
  • Placing it far from the source. It still works, but the unwanted traffic crosses the network before being dropped.
  • Mixing up direction. "In" and "out" are from the router's point of view: in is traffic entering the router through that interface.

💡 Exam tip: expect questions that give you an extended ACL and ask which packets it permits, so read each entry in order: protocol, source, source port, destination, destination port. Know that extended ACLs go close to the source, the number ranges (100-199, 2000-2699), how to insert and delete lines with sequence numbers in a named ACL, and that a packet matching nothing is denied. Common port numbers (22, 23, 53, 80, 443) are fair game.

Key takeaways

  • Extended ACLs match protocol, source, destination and TCP/UDP ports.
  • A port after the source is the source port; after the destination, the destination port.
  • Place extended ACLs close to the source.
  • Named ACLs are easier to read and edit; sequence numbers let you insert or remove single lines.
  • ACLs are stateless, and the implicit deny still applies.

Check yourself

Predict · scenario 1

Entry: 'permit tcp any host 192.168.30.10 eq 22'. Which packet does it match?

Predict · scenario 2

You add 'permit tcp 192.168.10.0 0.0.0.255 host 192.168.30.10 eq 80' at the end of SALES-IN, after 'permit ip any any'. Does it ever match?

Predict · scenario 3

Where should an extended ACL that blocks the Sales LAN from SRV1 be placed?

Predict · scenario 4

Inside 'ip access-list extended SALES-IN', you type 'no 30'. What happens?

Predict · scenario 5

An inbound ACL on R2's link to R1 contains only 'permit tcp any any eq 443'. Shortly after it is applied, the OSPF neighbour R1 goes down. Why?

FAQ

Is an ACL the same as a firewall?
Not quite. A Cisco IOS ACL is stateless: it checks each packet on its own and does not remember connections. A stateful firewall tracks each conversation and lets replies back in automatically. ACLs are fine for simple rules on routers, but they cannot follow a session the way a firewall does.
Can I put a port number on an 'ip' entry?
No. Ports belong to TCP and UDP, so you can only add eq, gt, lt, neq or range after addresses in a tcp or udp entry. An 'ip' entry matches every IP packet between the addresses, whatever the protocol.
How are IPv6 ACLs different?
IPv6 ACLs are always named (ipv6 access-list NAME) and are applied with ipv6 traffic-filter NAME in|out. They have no standard/extended split; every entry can match source, destination and ports. Their hidden final entries permit Neighbor Discovery messages before the implicit deny, so neighbours still work.
What does the 'established' keyword do?
On a tcp entry, 'established' matches only TCP segments with the ACK or RST flag set: that is, packets that belong to a connection already in progress. It is an old, simple way to let replies in without allowing new connections from outside. It is not real connection tracking, so modern designs use a stateful firewall instead.