Octet

Filter staff and guest traffic at a branch router with extended ACLs

Cisco IOSCore

Tasks

  1. Write a named extended ACL GUEST-IN that implements the guest policy and only accepts guest source addresses.
  2. Write a named extended ACL STAFF-IN that implements the staff policy and logs denied attempts to the servers.
  3. Apply both inbound on the right subinterfaces of R1.
  4. Restrict the VTY lines of R1 to SSH from the management subnet and the IT admin PC.
  5. Prove each rule with a test and the ACL counters.

Solution

  1. 1Guest ACLR1
    R1 on Cisco IOS
    ip access-list extended GUEST-IN
     remark DHCP from clients that have no address yet
     10 permit udp any eq bootpc any eq bootps
     remark DNS to the HQ resolver only
     20 permit udp 10.1.30.0 0.0.0.255 host 10.2.50.53 eq domain
     30 permit tcp 10.1.30.0 0.0.0.255 host 10.2.50.53 eq domain
     remark No private address space, including this router
     40 deny ip any 10.0.0.0 0.255.255.255 log
     50 deny ip any 172.16.0.0 0.15.255.255
     60 deny ip any 192.168.0.0 0.0.255.255
     remark Internet, from real guest addresses only
     70 permit ip 10.1.30.0 0.0.0.255 any

    Line 10 comes first because a DHCP DISCOVER has source 0.0.0.0, which no subnet line matches. Line 70 names the guest subnet instead of any, so spoofed sources fall into the implicit deny.

  2. 2Staff ACLR1
    R1 on Cisco IOS
    ip access-list extended STAFF-IN
     10 permit udp any eq bootpc any eq bootps
     20 permit tcp 10.1.20.0 0.0.0.255 10.2.50.0 0.0.0.255 eq 443
     30 permit udp 10.1.20.0 0.0.0.255 host 10.2.50.53 eq domain
     40 permit tcp 10.1.20.0 0.0.0.255 host 10.2.50.53 eq domain
     50 permit tcp host 10.1.20.5 10.2.50.0 0.0.0.255 eq 22
     60 deny ip 10.1.20.0 0.0.0.255 10.2.50.0 0.0.0.255 log
     70 permit ip 10.1.20.0 0.0.0.255 any

    Order matters: the specific permits for the server subnet sit above the deny for the same subnet. Line 60 also blocks ping from staff to the servers, which matches the policy as written.

  3. 3Apply the ACLs near the sourceR1
    R1 on Cisco IOS
    interface GigabitEthernet0/0/0.20
     ip access-group STAFF-IN in
    interface GigabitEthernet0/0/0.30
     ip access-group GUEST-IN in

    Inbound on the user-facing subinterfaces: unwanted traffic is dropped before it reaches the WAN, and the WAN interface with its OSPF adjacency is never touched. Return traffic toward the users leaves these subinterfaces outbound and is not filtered.

  4. 4VTY access with a standard ACLR1
    R1 on Cisco IOS
    ip access-list standard VTY-MGMT
     10 permit 10.99.0.0 0.0.0.255
     20 permit host 10.1.20.5
     30 deny any log
    !
    line vty 0 15
     access-class VTY-MGMT in
     transport input ssh

    On VTY lines only the source matters, so a standard ACL is the right tool. If management runs in a VRF, add vrf-also to the access-class.

Verify

GUEST1 output
GUEST1# ping -c 2 10.2.50.10
PING 10.2.50.10 (10.2.50.10) 56(84) bytes of data.
From 10.1.30.1 icmp_seq=1 Packet filtered
From 10.1.30.1 icmp_seq=2 Packet filtered

--- 10.2.50.10 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1001ms

R1 answers with ICMP administratively prohibited, which Linux prints as "Packet filtered". The guest cannot reach HQ servers.

STAFF1 output
STAFF1# ssh admin@10.2.50.10
ssh: connect to host 10.2.50.10 port 22: No route to host

Staff PCs other than 10.1.20.5 cannot SSH to the servers. R1 answers the SYN with ICMP administratively prohibited, which Linux reports as "No route to host". With no ip unreachables on the subinterface it would time out instead.

R1 output
R1# show logging | include IPACCESSLOG
%SEC-6-IPACCESSLOGP: list STAFF-IN denied tcp 10.1.20.30(50522) -> 10.2.50.10(22), 1 packet

The denied SSH attempt from STAFF1 (10.1.20.30) is logged against STAFF-IN.

R1 output
R1# show ip access-lists GUEST-IN
Extended IP access list GUEST-IN
    10 permit udp any eq bootpc any eq bootps (14 matches)
    20 permit udp 10.1.30.0 0.0.0.255 host 10.2.50.53 eq domain (312 matches)
    30 permit tcp 10.1.30.0 0.0.0.255 host 10.2.50.53 eq domain
    40 deny ip any 10.0.0.0 0.255.255.255 log (2 matches)
    50 deny ip any 172.16.0.0 0.15.255.255
    60 deny ip any 192.168.0.0 0.0.255.255
    70 permit ip 10.1.30.0 0.0.0.255 any (5820 matches)

DHCP, DNS and internet lines are counting. Line 40 has exactly the two pings from GUEST1. Lines with no counter have not matched yet.

R1 output
R1# show ip interface GigabitEthernet0/0/0.30 | include access list
  Outgoing Common access list is not set
  Outgoing access list is not set
  Inbound Common access list is not set
  Inbound  access list is GUEST-IN

GUEST-IN is applied inbound and nothing is applied outbound.

Mistakes people make

  • Forgetting the DHCP line. Clients without an address send from 0.0.0.0, which no subnet permit matches, so nobody gets a lease.
  • Applying the ACL outbound on the subinterface. That filters traffic going to the users, the opposite of the intent.
  • Forgetting that an inbound ACL also filters traffic to the router itself, such as pings to the gateway and SSH to R1.
  • Ending the guest ACL with permit ip any any, which also lets spoofed source addresses out.
  • Editing a live ACL by deleting and retyping it. Use sequence numbers to insert or remove single lines.

On other platforms

The guest policy as a Junos firewall filter. Junos filters also end with an implicit discard.

Junos
set firewall family inet filter GUEST-IN term dhcp from protocol udp
set firewall family inet filter GUEST-IN term dhcp from source-port 68
set firewall family inet filter GUEST-IN term dhcp from destination-port 67
set firewall family inet filter GUEST-IN term dhcp then accept
set firewall family inet filter GUEST-IN term dns from destination-address 10.2.50.53/32
set firewall family inet filter GUEST-IN term dns from protocol [ udp tcp ]
set firewall family inet filter GUEST-IN term dns from destination-port 53
set firewall family inet filter GUEST-IN term dns then accept
set firewall family inet filter GUEST-IN term private from destination-address 10.0.0.0/8
set firewall family inet filter GUEST-IN term private from destination-address 172.16.0.0/12
set firewall family inet filter GUEST-IN term private from destination-address 192.168.0.0/16
set firewall family inet filter GUEST-IN term private then discard
set firewall family inet filter GUEST-IN term internet from source-address 10.1.30.0/24
set firewall family inet filter GUEST-IN term internet then accept
set interfaces ge-0/0/0 unit 30 family inet filter input GUEST-IN

Say it in the interview

"I write named extended ACLs and put them inbound on the user-facing subinterfaces, close to the source. DHCP goes first because clients start from 0.0.0.0, specific permits go above the matching deny, and the final permit names the real subnet so spoofed sources hit the implicit deny. VTY access gets a standard ACL because only the source matters there. Then I prove each rule with a test and the counters."

Book 8.5 Example Systems