Learn / Stage 3: Networking and CCNA / Lesson 3.9

$ lesson 3.9 --track ccna --domain security

Access Control Lists: Standard, Extended, Named and VTY Protection

ACLs are the simplest traffic policy a router can enforce, and the easiest way to cause an outage. Learn how a packet walks the list, how wildcards work, where to put each type, how to edit a live ACL safely, and how to make sure only admins can even reach the login prompt.

  • Stage 3 Networking and CCNA
  • Level Intermediate to advanced
  • 65 min
  • 6 sections, quiz, lab

Start the lesson Jump to the lab

By the end of this lesson you can

  • Predict which line of an ACL matches a packet, including the implicit deny
  • Write wildcard masks for hosts, subnets and ranges
  • Configure numbered and named standard and extended ACLs
  • Choose the right interface and direction for each ACL
  • Restrict VTY access with access-class and read match counters
3.9.01

How an ACL decides

An access control list is an ordered list of permit and deny lines. When a packet is checked against it, the router:

  1. Compares the packet with the first line, then the next, top to bottom.
  2. Stops at the first line that matches and does what it says. Later lines are never read for that packet.
  3. If no line matches, drops the packet. Every ACL ends with an invisible deny any.

That last rule causes the classic outage: an ACL with only deny host 192.168.10.10 does block that host, and it also blocks everyone else, because nothing is permitted. If you mean "everyone except this host", add permit any at the end.

Standard and extended ACLs
TypeNumbersMatches onPlace it
Standard1 to 99, 1300 to 1999Source IP onlyClose to the destination, so it does not block the source from everywhere else.
Extended100 to 199, 2000 to 2699Protocol, source, destination, ports, some flagsClose to the source, so unwanted traffic is dropped before it crosses the network.

On an interface you get one ACL per direction per protocol: one IPv4 ACL in, one out. "In" means packets arriving on that interface, before routing. "Out" means packets leaving it, after routing. Outbound ACLs do not filter packets the router itself generates, such as its own pings or routing updates.

3.9.02

Wildcard masks

ACLs (and OSPF network statements) use wildcard masks: a 0 bit means "this bit must match", a 1 bit means "ignore this bit". For a normal subnet the wildcard is the subnet mask inverted, which you can get by subtracting each octet from 255.

Wildcard examples
To matchAddress and wildcardShortcut
One host192.168.10.10 0.0.0.0host 192.168.10.10
A /24192.168.20.0 0.0.0.255
A /26 (64 addresses)192.168.20.64 0.0.0.63
A /3010.0.13.0 0.0.0.3
All of 192.168.0.0 to 192.168.255.255192.168.0.0 0.0.255.255
Everything0.0.0.0 255.255.255.255any

Wildcards can also match patterns a subnet mask cannot. 192.168.1.0 0.0.254.255 matches every odd third octet (192.168.1.x, 192.168.3.x and so on). You will rarely write one, but you should recognise that a wildcard is not always a contiguous block.

3.9.03

Numbered, named and extended syntax

! numbered standard
R1(config)#access-list 10 deny host 192.168.10.10
R1(config)#access-list 10 permit any
! named extended, with sequence numbers
R1(config)#ip access-list extended GUEST-IN
R1(config-ext-nacl)#10 permit udp 192.168.20.0 0.0.0.255 host 10.10.10.10 eq domain
R1(config-ext-nacl)#20 permit tcp 192.168.20.0 0.0.0.255 host 10.10.10.10 eq www
R1(config-ext-nacl)#30 deny ip 192.168.20.0 0.0.0.255 192.168.0.0 0.0.255.255 log
R1(config-ext-nacl)#40 permit ip 192.168.20.0 0.0.0.255 any
! insert or delete one line later
R1(config-ext-nacl)#15 permit icmp 192.168.20.0 0.0.0.255 host 10.10.10.10 echo
R1(config-ext-nacl)#no 30
! apply
R1(config)#interface GigabitEthernet0/0/0.20
R1(config-subif)#ip access-group GUEST-IN in
  • Extended line order: action protocol source [source port] destination [destination port] [options]. Ports need tcp or udp.
  • Port operators: eq, neq, gt, lt, range. Names like www (80) and domain (53) are accepted.
  • established matches TCP packets with ACK or RST set, which is a cheap way to allow replies. It is a flag check, not session tracking, so it is not a stateful firewall.
  • Named ACLs give each line a sequence number, so you can insert line 15 between 10 and 20 or delete one line, instead of deleting and retyping a numbered list.
3.9.04

Try it: walk a packet through GUEST-IN

This is the guest VLAN policy from the lab. Pick an example packet, or edit the ACL and type your own, then read the trace to see exactly which line decided.

ACL rule tester

Edit the ACL, describe a packet, and watch it walk the list top to bottom. The first matching line decides. If nothing matches, the invisible deny at the end drops it.

Packet

    Notice the last example. GUEST-IN only matches guest sources, so a staff packet falls through to the implicit deny. That is fine, because the ACL is applied only on the guest subinterface, but it shows why applying an ACL to the wrong interface breaks things.

    3.9.05

    Protecting the router itself

    An ACL on a data interface does not protect SSH to the router from every direction. For the VTY lines use access-class, which filters who may open a remote session, whichever interface they arrive on.

    R1(config)#ip access-list standard MGMT-ONLY
    R1(config-std-nacl)#permit 192.168.99.0 0.0.0.255
    R1(config-std-nacl)#deny any log
    R1(config)#line vty 0 4
    R1(config-line)#access-class MGMT-ONLY in
    3.9.06

    Practise on R1

    R1 already routes for VLANs 10, 20 and 99 (router on a stick, as in lesson 3.6) and reaches the server LAN on Gi0/0/1. Match counters in this console are sample numbers, standing in for real traffic.

    console: R1 (R1 ACL console)

    Missions 0/12

      Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.

      Flashcards: do you remember?

      Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.

      Quick quiz

      Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.

      Q1An ACL contains only access-list 5 deny host 10.1.1.5 and is applied. What happens to traffic from 10.1.1.6?

      Q2Which wildcard matches 172.16.8.0/22?

      Q3Where should an extended ACL that blocks guests from staff be placed?

      Q4How do you stop non-admins reaching SSH on a router?

      Q5permit tcp any host 10.1.1.1 eq 22 established matches:

      Q6How many IPv4 ACLs can be applied inbound on one interface?

      0 / 6

      Hands-on lab

      Cisco Packet Tracer lab50 minutessimulated network

      Packet Tracer lab 3.9: segment guests and lock down management

      You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Start from your lesson 3.6 router on a stick file, or build it: 1 x ISR4331, 2 x 2960, 3 x PC-PT, 1 x Server-PT. SSH from lesson 3.3 should already work on R1 and SW1.

      Topology and addressing

      Lab 3.9 topology: router on a stick for VLANs 10, 20 and 99, with a web and DNS server behind R1 Gi0/0/1Gi0/0/0 .10 .20 .99Gi0/1 trunkGi0/0/1 10.10.10.1VLAN 10VLAN 20VLAN 99R1ISR4331SW12960, SVI .99.2SW2PC-Staff192.168.10.10PC-Guest192.168.20.10Admin-PC192.168.99.10Server-Web10.10.10.10
      R1 Gi0/0/0 trunks to SW1 with subinterfaces .10, .20 and .99. R1 Gi0/0/1 to SW2 and Server-Web.
      Addressing table
      DeviceInterfaceIPv4 address / prefixDefault gateway or note
      R1Gi0/0/0.10 / .20 / .99192.168.10.1 / 192.168.20.1 / 192.168.99.1 (/24)gateways for each VLAN
      R1Gi0/0/110.10.10.1/24server LAN
      SW1VLAN 99192.168.99.2/24gateway 192.168.99.1
      PC-Staff / PC-Guest / Admin-PCFa0192.168.10.10 / 192.168.20.10 / 192.168.99.10gateway .1
      Server-WebFa010.10.10.10/24gateway 10.10.10.1, HTTP and DNS on
      1. Guest policy, close to the source

        ip access-list extended GUEST-IN
         10 permit udp 192.168.20.0 0.0.0.255 host 10.10.10.10 eq domain
         20 permit tcp 192.168.20.0 0.0.0.255 host 10.10.10.10 eq www
         30 deny ip 192.168.20.0 0.0.0.255 192.168.0.0 0.0.255.255 log
         35 deny ip 192.168.20.0 0.0.0.255 10.0.0.0 0.255.255.255 log
         40 permit ip 192.168.20.0 0.0.0.255 any
        interface GigabitEthernet0/0/0.20
         ip access-group GUEST-IN in
      2. Management lockdown (R1 and SW1)

        ip access-list standard MGMT-ONLY
         permit 192.168.99.0 0.0.0.255
         deny any log
        line vty 0 4
         access-class MGMT-ONLY in

        On SW1 apply it to line vty 0 15 if that range exists in your model.

      3. Insert a line without retyping

        R1(config)#ip access-list extended GUEST-IN
        R1(config-ext-nacl)#15 permit icmp 192.168.20.0 0.0.0.255 host 10.10.10.10 echo
      4. Standard ACL near the destination

        R1(config)#access-list 10 deny host 192.168.10.10
        R1(config)#access-list 10 permit any
        R1(config)#interface GigabitEthernet0/0/1
        R1(config-if)#ip access-group 10 out
      5. Test from each PC

        From PC-Guest: browse http://10.10.10.10 (works), ping 10.10.10.10 (works after step 3), ping 192.168.10.10 (fails), SSH to 192.168.99.1 (fails). From PC-Staff: browse the server (fails after step 4). From Admin-PC: SSH to R1 (works).

      6. Verify

        R1#show access-lists
        R1#show ip interface GigabitEthernet0/0/0.20
        R1#show running-config | section vty

      You are done when: show access-lists shows every line with a sequence number and match counters that rise only on the lines your tests hit. show ip interface for Gi0/0/0.20 reports GUEST-IN as the inbound list. The VTY section shows access-class MGMT-ONLY in. PC-Staff cannot reach the server but PC-Guest can, because ACL 10 filters by source only.

      Packet Tracer limits and notes

      • Numbered and named standard and extended ACLs, sequence numbers and access-class work in Packet Tracer in the outline author's experience, but test in your own build.
      • The log keyword is accepted, but whether Packet Tracer actually generates log messages for ACL hits is UNVERIFIED. Rely on the match counters.
      • IPv6 ACLs (ipv6 access-list with ipv6 traffic-filter) follow the same ideas but are not part of this lab.
      • Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.

      Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.

      Key takeaways

      • First match wins, and every ACL ends with an invisible deny any.
      • Standard near the destination, extended near the source.
      • Wildcard = 255 minus each mask octet for normal subnets.
      • Use named ACLs so you can insert and delete single lines.
      • Protect the management plane with access-class, and log the denies that matter.

      Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.