Free tech learning for everyone, from basics to pro

Network SecurityNetworking SecurityIntermediate

Securing switches and routers: VLANs, port security, DHCP snooping and ACLs

In short: Switches tie devices together and routers connect networks. Secure them with VLAN segmentation, port security to limit which devices can connect, DHCP snooping to block rogue DHCP servers, and access control lists to filter traffic. NAT then hides private addresses.

Switches and VLANs

A switch connects computers, printers and servers so they can share resources and talk to each other anywhere in a building or campus. VLANs split one physical switched network into several logical networks, each its own broadcast domain; traffic between VLANs must pass through a router. VLANs:

  • reduce broadcast traffic and the size of broadcast domains;
  • add a layer of security by separating groups;
  • group devices by function instead of location;
  • make management easier.
VLAN typePurposeSecurity tip
Default VLAN (VLAN 1)All ports start hereDon't use it for user or management traffic
Data VLANCarries user traffic for a groupOne VLAN per role or department
Native VLANCarries untagged traffic on a trunkChange it to an unused VLAN
Management VLANSSH, SNMP, syslog to devicesSeparate, restricted VLAN
Voice VLANIP phone traffic with prioritySeparate from data

A trunk carries many VLANs between switches, adding an IEEE 802.1Q tag to each frame. Disable automatic trunk negotiation on user ports to stop VLAN-hopping attacks.

Port security

A switch learns MAC addresses as frames arrive. Port security limits how many MAC addresses a port may learn, can fix ("sticky") the allowed addresses, and applies a penalty when an unknown device connects:

  • Shutdown (default): the port is disabled (err-disabled) and an alert is logged.
  • Restrict: unknown traffic is dropped and logged.
  • Protect: unknown traffic is dropped silently.

DHCP snooping

DHCP snooping trusted and untrusted portsAccess switchDHCP snooping onReal DHCP servertrusted portPCPCRogue DHCPuntrusted: serverreplies droppeduntrusted ports
Figure 1. DHCP snooping only accepts DHCP server messages from the trusted uplink, so a rogue server can't hand out fake settings.

DHCP snooping marks the uplink to the real DHCP server as trusted and every user port as untrusted. The switch then drops:

  • DHCP server messages arriving on untrusted ports (rogue servers);
  • client messages that don't match its binding table or exceed rate limits;
  • relay messages carrying option 82 information on untrusted ports.

Its binding table also powers Dynamic ARP Inspection, which stops ARP spoofing.

Routers and access control lists

A router connects networks, such as several switched LANs, branch sites and the internet. An Access Control List (ACL) is an ordered list of permit and deny rules applied to traffic entering or leaving an interface. Rules are checked top to bottom, and an invisible deny all sits at the end.

Where to place standard and extended ACLsSource LAN10.1.1.0/24R1R2Server LAN10.2.2.0/24Extended ACL hereStandard ACL here
Figure 2. Extended ACLs go close to the source; standard ACLs (source address only) go close to the destination.
  • Standard ACL (numbers 1–99): checks only the source IP address. Less CPU work, less precise.
  • Extended ACL (numbers 100–199 or named): checks source and destination addresses, protocol and ports. More precise, more CPU work.

NAT on the network edge

NAT changes IP addresses (and ports) as packets cross a router or firewall. It reduces how many public addresses a company needs and hides internal address ranges.

  1. Static NAT: one private address always maps to the same public address (for servers).
  2. Dynamic NAT: private addresses borrow addresses from a pool of public ones.
  3. PAT (NAT overload): many devices share one public address, each with a different port number.

NAT hides addresses but is not a firewall: always filter traffic too. Device commands for all of these are in the switch and router command pages.

Real-world example: segmenting a primary school

A primary school ran staff PCs, pupil tablets, the office printer and the CCTV recorder on one flat network. A pupil's tablet could reach the CCTV recorder's web login page. The school's IT support company split the network into four VLANs: staff, pupils, printers and CCTV. Access ports were set to a single VLAN with port security limited to two MAC addresses, unused ports were shut down, and DHCP snooping was enabled so that only the server uplink could hand out addresses.

On the router, an access control list allowed the pupil VLAN to reach only the internet and the printers, and blocked it from the staff and CCTV VLANs. NAT continued to share the school's single public address. The change took one evening, and the CCTV system was no longer visible to anyone outside the office.

Practice

A port with port security set to shutdown sees an unknown MAC address. What happens?
The port is err-disabled and an alert is logged; an administrator must re-enable it.
Which ports are trusted in DHCP snooping?
Only the ports leading to legitimate DHCP servers (usually uplinks); user ports are untrusted.
Where should an extended ACL be placed, and why?
Close to the source, so unwanted traffic is dropped before it crosses the network.

Key takeaways

  • VLANs segment networks; avoid VLAN 1, change the native VLAN and separate management and voice.
  • Port security limits MAC addresses per port with shutdown, restrict or protect actions.
  • DHCP snooping blocks rogue DHCP servers and enables ARP inspection.
  • Standard ACLs check source only (place near destination); extended ACLs check much more (place near source).
  • NAT types: static, dynamic and PAT; NAT is not a substitute for a firewall.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.