How an ACL works: top-down processing, implicit deny, standard and extended ACLs
This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.
Key points
- An ACL is checked top-down. When a packet matches a statement it is permitted or denied immediately, and the remaining statements are skipped.
- At the end of every ACL there is an invisible
deny any: anything not explicitly permitted is dropped. - A standard ACL only looks at the source IP: number 1-99 or 1300-1999. An extended ACL looks at source/destination IP, protocol and ports: 100-199 or 2000-2699. Both can also have a name.
- Only one ACL per direction (in/out) on an interface. Put the most specific statements at the top. An ACL is created globally first, then applied to an interface.
- Special types: dynamic (lock-and-key, authenticate with Telnet first), reflexive (temporary permission for return traffic), time-based (active on certain days and hours).
An ACL is made of statements
Let's look at what an ACL looks like:
R1#show access-lists Standard IP access list 1 10 permit 10.10.1.0, wildcard bits 0.0.0.255 20 permit 10.10.2.0, wildcard bits 0.0.0.255 30 permit 172.20.0.0, wildcard bits 0.0.255.255
An ACL is made of statements. Here ACL number 1 has three statements: 10, 20 and 30. These numbers are sequence numbers; by default the router starts at 10 and increases them in steps of 10.
We will cover wildcard bits in detail in the next lesson. For now, know that 0.0.0.255 means "the last octet can be anything", so 10.10.1.0 0.0.0.255 is the whole 10.10.1.0 /24 network.
Top-down processing
When a packet reaches an ACL, this is what happens:
- The ACL is checked top-down: first we check whether the packet matches statement 10.
- If it does not match 10, statement 20 is checked.
- If it does not match 20, statement 30 is checked.
- If it does not match 30 either, the packet is dropped.
As soon as a packet matches a statement, a decision is made immediately: the packet is either permitted (forwarded) or denied (dropped). For example, the packet in the figure (source 10.10.2.7) matches statement 20 and is permitted. The router does not check whether it "also" matches statement 30.
The invisible deny any
Why was the packet dropped in step 4? Because at the end of every ACL there is an invisible deny any. Anything you did not explicitly permit is dropped. You don't see this line in the show access-lists output, but it is there.
Remember: if an ACL contains only deny statements and you don't add at least one permit statement at the end, the ACL will block all traffic.
Standard and extended ACLs
There are two main types of ACL:
| Type | What it looks at |
|---|---|
| Standard ACL | Only the source IP address |
| Extended ACL | Source and destination IP address, protocol (IP, ICMP, TCP, UDP, OSPF...), source and destination port (TCP/UDP) |
A standard ACL is very simple: it can only check the source IP address and cannot do anything more specific. An extended ACL gives many more options: it can check the source and destination IP as well as transport layer (layer 4) information, such as a TCP or UDP port number.
That does not make standard ACLs bad. Sometimes the source IP is all we care about: for example, to define which networks a VPN selects or who may connect to the VTY lines, a standard ACL is enough.
How to recognize an ACL
| IPv4 ACL type | Number / name |
|---|---|
| Standard | 1-99 or 1300-1999 |
| Extended | 100-199 or 2000-2699 |
| Named | Any name you like |
- For a standard ACL, choose a number from 1-99 or 1300-1999.
- For an extended ACL, choose a number from 100-199 or 2000-2699.
- If you don't want a number, you can create a named ACL. A name works for both standard and extended ACLs.
Rules when building ACLs
- An ACL is first created in global configuration and then applied to an interface.
- An interface can have only one ACL per direction (per protocol). So an interface cannot have two inbound IPv4 ACLs. One inbound and one outbound is fine.
- Put the most specific statements at the top. As soon as a packet matches a statement the router ignores the rest, so if a general statement is above it, the specific statement below will never be used.
- Don't forget the last statement is
deny any: you don't see it, but it is there. - Cisco recommendation: place an extended ACL as close as possible to the source of the traffic. Because a standard ACL only looks at the source, place it as close as possible to the destination, so that it does not cut off traffic that should pass.
- If you run a routing protocol, make sure the ACL does not block your RIP, EIGRP or OSPF traffic.
What else can ACLs do?
Dynamic ACL (lock-and-key). A user who wants to reach a server first has to connect to the router with Telnet and authenticate; only then is access opened. But having users connect directly to routers is not a good idea. There are better solutions for this: 802.1X and RADIUS.
Reflexive ACL. When building ACLs you have to be careful not to drop legitimate traffic.
There is an inbound ACL on the router's left interface, so the computer outside cannot reach the internal network with the server. That's good. But now the server wants to communicate with the computer outside. Traffic going out is permitted, but the return traffic will be dropped by the ACL. A reflexive ACL makes sure return traffic can come back into the network: it automatically creates temporary entries in the ACL for the return traffic.
Time-based ACL. An ACL that is only active at certain times: for example, on weekdays between 09:00 and 17:00, or any other days and hours you like.
Check yourself
5 questions · answers are shown instantly · 3 correct answers complete the lesson
1A packet matches statement 10 of an ACL. Does the router check statement 20?
2A packet does not match any statement in the ACL. What happens?
3What can a standard ACL look at?
4Which type of ACL is access-list 2050?
5How many inbound IPv4 ACLs can an interface have?
Comments
Sign in to comment.