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 8080, port 443443, port 2121, port 80808080, 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 255.255.255.255255.255.255.255.

  • Wildcard Mask Keywords:

    • any: Replaces the address and mask 0.0.0.0 255.255.255.2550.0.0.0\,255.255.255.255. It is used to permit or deny all networks/traffic (e.g., access-list 1 permit any).
    • host: Replaces the wildcard mask 0.0.0.00.0.0.0. It is used to match a single specific IP address (e.g., access-list 1 permit host 192.168.10.10 is the same as access-list 1 permit 192.168.10.10 0.0.0.0).

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 0/00/0).
  • 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

FeatureStandard ACLExtended ACL
Number Range (Normal)11 to 9999100100 to 199199
Number Range (Expanded)13001300 to 1999199920002000 to 26992699
PlacementClose to destinationClose to source
Filtering CriteriaSource IP address onlySource/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:

    1. Use the no ip access-group command on the interface to unlink it.
    2. Use the global configuration no access-list [number] command to delete the list entirely.
  • Named Standard ACLs:

    1. Start with the ip access-list standard [name] command.
    2. The name must be alphanumeric, unique, and cannot begin with a number.
    3. Enter ACEs using the permit, deny, or remark keywords.
    4. Apply to the interface using ip access-group [name] [in | out].

Modifying and Verifying ACLs

  • Modification Method 1 (Text Editor):

    1. Use show run to view the existing ACL.
    2. Copy and paste the statements into a text editor (e.g., Notepad).
    3. Edit the statements as needed.
    4. Delete the old ACL on the router using the no access-list command.
    5. Copy and paste the corrected ACL back into the router.
  • 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 77 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 100100 to 199199 or 20002000 to 26992699.
    • protocol: Name or number (e.g., icmp, ip, tcp, udp). ip matches 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), and range (inclusive range).
    • port: The decimal number or name of the TCP/UDP port (e.g., 8080 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 tcp instead of udp (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.