Cisco Access Control Lists (ACLs) Comprehensive Study Notes
Overview of IP ACL Operation
Definition of Packet Filtering: Packet filtering, also known as static packet filtering, is the process used to allow or deny a packet to pass through a router based on specific criteria. The router acts as a packet filter when it forwards or denies packets according to established filtering rules.
Filtering Criteria: Packet filtering criteria include:
- The source IP address and/or the destination IP address.
- The source port and/or the destination port.
- The protocol carried within the packet.
Access Control Lists (ACLs): An ACL is a sequential list of permit or deny statements. These individual statements are known as Access Control Entries (ACEs).
Implicit Deny Logic:
- An ACL is composed of various ACEs (different permit or deny statements).
- The last statement of an ACL is always an "implicit deny." This statement is automatically inserted by the system even though it is not physically visible in the configuration.
- During processing, packets are compared against the ACEs line by line, starting from the top and moving to the bottom.
- If no match is found after checking the packet against the final physical ACE, the implicit deny kicks in, and the packet is denied and discarded.
ACL Directionality:
- ACLs must be configured to filter traffic in a specific direction: inbound or outbound.
- Inbound Traffic: Packets are checked as soon as they reach the router interface.
- Outbound Traffic: Packets are checked only after a routing decision is made and just before they leave the router interface.
Standard and Extended IPv4 ACLs
Standard ACLs: These ACLs filter packets based on the Source IP Address only.
Extended ACLs: These ACLs provide more granular control and filter packets based on:
- Source IP address and Destination IP address.
- Source port number and Destination port number.
- Protocol type or Protocol number (e.g., IP, ICMP, TCP, UDP, port , port , port , port , etc.).
Identification Methods: Both standard and extended ACLs can be identified using either a specific number or a unique name.
Wildcard Masking in ACLs
Function of Wildcard Masks: ACLs use wildcard masks to determine which bits of an address to match or ignore.
Wildcard Mask Rules:
- Bit 0: Match the corresponding bit value in the address.
- Bit 1: Ignore the corresponding bit value in the address.
Converting Subnet Masks to Wildcard Masks: To calculate a wildcard mask, subtract the subnet mask from .
Wildcard Mask Keywords:
- any: Replaces the address and mask . It is used to permit or deny all networks/traffic (e.g.,
access-list 1 permit any). - host: Replaces the wildcard mask . It is used to match a single specific IP address (e.g.,
access-list 1 permit host 192.168.10.10is the same asaccess-list 1 permit 192.168.10.10 0.0.0.0).
- any: Replaces the address and mask . It is used to permit or deny all networks/traffic (e.g.,
Guidelines and Best Practices for ACL Creation
Placement Restriction: ACLs can and should only be created on routers.
The Three Ps Rule:
- One ACL per Protocol: An ACL must be defined for each protocol enabled on an interface to control its traffic flow.
- One ACL per Direction: ACLs only control traffic in a single direction at a time. Separate ACLs are required for inbound and outbound traffic.
- One ACL per Interface: ACLs control traffic for a specific interface (e.g., GigabitEthernet ).
Placement Efficiency Rules:
- Standard ACLs: Should be placed as close as possible to the destination of the traffic to be filtered. This is because they only check the source address; placing them near the source might inadvertently block the host from reaching other legitimate destinations.
- Extended ACLs: Should be placed as close as possible to the source of the traffic to be filtered. This conserves bandwidth by dropping unwanted traffic before it crosses the network backbone.
Additional Placement Factors:
- The extent of the network administrator's control.
- Bandwidth availability of the networks involved.
- Ease of configuration.
Comparison of Standard and Extended ACLs
| Feature | Standard ACL | Extended ACL |
|---|---|---|
| Number Range (Normal) | to | to |
| Number Range (Expanded) | to | to |
| Placement | Close to destination | Close to source |
| Filtering Criteria | Source IP address only | Source/Dest IP, Port numbers, Protocol type |
Configuring Standard IPv4 ACLs
Statement Order: Access list statements are processed sequentially. If a specific "deny" statement for a single host is placed after a "permit" statement for that host's whole network, the deny statement will never be reached. The most specific statements should be at the top.
Configuration Command Syntax:
Router(config)# access-list access-list-number deny | permit | remark source [ source-wildcard ] [ log ]Remark Keyword: Used for documentation purposes to make the ACL easier to understand.
Applying to Interfaces: Once created, an ACL must be linked to an interface:
Router(config-if)# ip access-group { access-list-number | access-list-name } { in | out }Removal of ACLs:
- Use the
no ip access-groupcommand on the interface to unlink it. - Use the global configuration
no access-list [number]command to delete the list entirely.
- Use the
Named Standard ACLs:
- Start with the
ip access-list standard [name]command. - The name must be alphanumeric, unique, and cannot begin with a number.
- Enter ACEs using the
permit,deny, orremarkkeywords. - Apply to the interface using
ip access-group [name] [in | out].
- Start with the
Modifying and Verifying ACLs
Modification Method 1 (Text Editor):
- Use
show runto view the existing ACL. - Copy and paste the statements into a text editor (e.g., Notepad).
- Edit the statements as needed.
- Delete the old ACL on the router using the
no access-listcommand. - Copy and paste the corrected ACL back into the router.
- Use
Modification Method 2 (Sequence Numbers): ACLs can be edited by referencing specific sequence numbers to insert or delete individual lines.
Verification Commands:
show running-config: Shows the ACL within the full configuration.show access-lists: Displays the ACEs and the number of packet matches (statistics) for each statement.show ip interface: Verifies if an ACL is applied to an interface and in which direction.
Securing VTY Ports with Standard ACLs
While filtering Telnet/SSH (Layer protocols) is usually an extended ACL function, a standard ACL can be used to secure VTY lines by filtering based on the source address of the administrator's workstation.
Configuration Syntax:
Router(config)# line vty 0 15Router(config-line)# access-class access-list-number { in [ vrf-also ] | out }Example:access-class 21 in
Structure and Configuration of Extended IPv4 ACLs
Extended ACL Command Syntax:
access-list access-list-number (deny | permit | remark) protocol source [source-wildcard] [operator operand] [port port-number or name] destination [destination-wildcard] [operator operand] [port port-number or name] [established]Parameter Details:
- access-list-number: Uses ranges to or to .
- protocol: Name or number (e.g.,
icmp,ip,tcp,udp).ipmatches all protocols. - source / destination: Identifies source and destination network or host addresses.
- operator: Optional comparison for ports:
lt(less than),gt(greater than),eq(equal),neq(not equal), andrange(inclusive range). - port: The decimal number or name of the TCP/UDP port (e.g., or
www). - established: (TCP only) Matches traffic that is part of an existing connection.
Common ACL Troubleshooting Errors
- Error #1: Wrong Statement Order. Placing general statements before specific ones prevents specific rules from being evaluated.
- Error #2: Wrong Protocol. For example, attempting to filter TFTP traffic using
tcpinstead ofudp(as TFTP uses UDP). - Error #3: Wrong Address Reference. Restricting a port (like Telnet) for a source address when the policy intended to restrict the destination address.
- Error #4: Missing Statements. If there is no specific statement allowing the traffic, it will be blocked by the implicit deny.
- Error #5: Wrong Direction/Interface. Applying an inbound ACL when the traffic needs to be filtered as it exits (outbound), or vice versa.