CCNA Lab 5: ACLs on Layer 2 Switches
ACLs (Access Control Lists) on switches come in three varieties, each serving a different purpose.
| ACL Type | Applied To | Filters |
|---|---|---|
| Port ACL (PACL) | Layer 2 interface | Ingress traffic on a port |
| VLAN ACL (VACL) | VLAN | All traffic entering the VLAN |
| Router ACL (RACL) | SVI / Routed interface | Inter-VLAN traffic |
Port ACLs apply to traffic entering a switch port. They filter at Layer 2 and can use both MAC and IP addresses.
ip access-list standard BLOCK_10
deny 10.0.0.0 0.255.255.255
permit any
interface GigabitEthernet0/1
ip access-group BLOCK_10 inBlock a specific MAC address from accessing the network:
mac access-list extended BLOCK_MAC
deny any host 00:11:22:33:44:55
permit any any
interface GigabitEthernet0/2
mac access-group BLOCK_MAC inBlock a specific host on a port from reaching specific services:
ip access-list extended RESTRICT_HOST
deny tcp host 10.0.10.50 any eq 22
deny tcp host 10.0.10.50 any eq 443
permit ip any any
interface GigabitEthernet0/3
ip access-group RESTRICT_HOST inVACLs filter all traffic entering a VLAN, regardless of port.
ip access-list extended BLOCK_P2P
deny tcp any any eq 6881
deny tcp any any range 6881 6889
permit ip any any
vlan access-map BLOCK_P2P 10
match ip address BLOCK_P2P
action drop
vlan access-map BLOCK_P2P 20
action forward
vlan filter BLOCK_P2P vlan-list 10,20This blocks BitTorrent traffic on VLANs 10 and 20.
Apply ACLs to SVIs (Switch Virtual Interfaces) to control traffic between VLANs.
ip access-list extended INTER_VLAN
remark Allow management to servers
permit ip 10.0.0.0 0.255.255.255 10.0.0.0 0.255.255.255
remark Deny everything else
deny ip any any
interface Vlan10
ip access-group INTER_VLAN inEvery ACL ends with an implicit deny any. If you forget the permit any at the end, all traffic not explicitly permitted is dropped.
! This blocks everything except HTTP and HTTPS
ip access-list extended WEB_ONLY
permit tcp any any eq 80
permit tcp any any eq 443
! Everything else is DENIEDApply ACLs in the correct direction:
ACLs process top-to-bottom. The first match wins. Put specific rules before general rules:
! Correct
ip access-list extended CORRECT
permit tcp host 10.0.0.1 host 10.0.0.2 eq 22 ! specific first
deny tcp any any eq 22 ! general after
! Wrong β the deny catches everything including 10.0.0.1
ip access-list extended WRONG
deny tcp any any eq 22 ! matches first
permit tcp host 10.0.0.1 host 10.0.0.2 eq 22 ! never reachedOn a switch port, these features apply in order:
A packet must pass ALL applicable ACLs. If a PACL denies and a VACL permits, the packet is still dropped.
show access-lists
show ip access-lists
show mac access-lists
show vlan access-map
show running-config | section access-listCount hits:
show access-lists BLOCK_P2P
Extended IP access list BLOCK_P2P
10 deny tcp any any eq 6881 (15 matches)
20 deny tcp any any range 6881 6889 (3 matches)
30 permit ip any any
deny ip any any log at the end of every ACL for loggingBLOCK_RDP_WAN or ALLOW_MGMT_ONLYremark to document each entryβs purposeip access-list extended mode (vs legacy access-list) for easy editingRelated Articles
CCNA Lab 5: ACLs on Layer 2 Switches
Configure and troubleshoot ACLs on Cisco switches β port ACLs, VLAN ACLs, and router ACLs. Secure your Layer 2 network.
CCNA Lab 2: VLANs, Trunking, and Layer 2 Fundamentals
Configure VLANs, trunk ports, VTP, and troubleshoot common Layer 2 issues on Cisco switches. Practical lab scenarios included.
CCNA Lab 12: DHCP Snooping, DAI, and IP Source Guard
Configure Layer 2 security features to prevent DHCP spoofing, ARP poisoning, and IP spoofing attacks on your access switches.