In short
- End-device ports are configured as access ports; switch–firewall–access point links as trunks.
- Each VLAN’s gateway is an 802.1Q sub-interface on the firewall; addresses can be handed out by the DHCP server through DHCP relay.
- Disable DTP, make the native VLAN an empty VLAN, shut down unused ports and enable DHCP snooping.
We covered what a VLAN is and what it does for a business in What is a VLAN?. This article summarises the implementation side for IT teams: switch ports, firewall interfaces, DHCP and security settings. The command examples use the widely known Cisco IOS syntax; with HPE Aruba, Ubiquiti, Fortinet and other vendors the concepts are the same but the commands differ.
1. Finalise the plan
Before you start configuring, fill in this table: VLAN number, name, IP range, gateway address, DHCP scope, and which VLANs this one may reach on which ports. In the examples below the gateway is the .1 address of each VLAN, and the DHCP and DNS server is 10.10.20.10 (Windows Server) in the server VLAN.
2. Switch: create the VLANs and assign ports
! VLAN definitions
vlan 10
name MANAGEMENT
vlan 20
name SERVERS
vlan 30
name STAFF
vlan 40
name VOICE
vlan 50
name CAMERA-IOT
vlan 99
name GUEST
vlan 999
name UNUSED
! Staff PC + IP phone port
interface GigabitEthernet1/0/10
description STAFF-DESK-12
switchport mode access
switchport access vlan 30
switchport voice vlan 40
spanning-tree portfast
spanning-tree bpduguard enable
! Trunk to the firewall
interface GigabitEthernet1/0/48
description FIREWALL-TRUNK
switchport mode trunk
switchport trunk native vlan 999
switchport trunk allowed vlan 10,20,30,40,50,99
switchport nonegotiate
Some older Catalyst models need switchport trunk encapsulation dot1q before switchport mode trunk. Only allow the VLANs that are really needed on a trunk; the “all VLANs” default means a VLAN added later is carried everywhere without anyone intending it.
3. Wireless access points
The port an access point is connected to should also be a trunk. The usual approach: the access point’s own management address sits in the management VLAN, and each SSID is carried tagged in its own VLAN. In the wireless controller or cloud management portal, map the “Company” SSID to VLAN 30 and the “Guest” SSID to VLAN 99; client isolation should also be enabled on the guest SSID.
4. Firewall: sub-interfaces and gateways
On the firewall port connected to the switch, create an 802.1Q sub-interface (VLAN interface) for each VLAN and give it the VLAN’s gateway address, such as 10.10.30.1/24 for VLAN 30 and 10.10.99.1/24 for VLAN 99. Each sub-interface should be defined as a separate zone on the firewall, so traffic between VLANs is blocked by default and opened only by rules.
- Allow access to the management interface (HTTPS, SSH) only from the management VLAN
- In the guest VLAN, allow only the firewall’s DHCP and DNS services and block all access to internal networks
- Block internet access for the camera VLAN, or limit it to the vendor’s update addresses
- Write inter-zone rules according to an access matrix: firewall rule review
5. DHCP: scopes and relay
DHCP requests are broadcasts, so they can’t cross a VLAN boundary. There are two options: run DHCP for each VLAN on the firewall, or forward requests to a central Windows DHCP server using DHCP relay. In a domain environment the second is usually preferred: on the firewall or layer 3 switch, set the DHCP server as the relay target for each VLAN interface (on Cisco, ip helper-address 10.10.20.10). On the Windows DHCP server, create a scope for each VLAN:
# Scope for the staff VLAN
Add-DhcpServerv4Scope -Name "STAFF (VLAN 30)" -StartRange 10.10.30.50 -EndRange 10.10.30.250 `
-SubnetMask 255.255.255.0 -LeaseDuration 8.00:00:00
Set-DhcpServerv4OptionValue -ScopeId 10.10.30.0 -Router 10.10.30.1 -DnsServer 10.10.20.10 -DnsDomain company.local
# Reservation for a printer
Add-DhcpServerv4Reservation -ScopeId 10.10.50.0 -IPAddress 10.10.50.20 -ClientId "00-11-22-33-44-55" -Name "Printer-Accounts"
For relay to work, the firewall rules must allow UDP 67 from the relevant VLAN interface to the DHCP server. Running DHCP for the guest VLAN on the firewall means guests never touch the server VLAN at all.
6. Protection against VLAN hopping and layer 2 attacks
- Disable DTP: set end-device ports explicitly to
switchport mode accessand useswitchport nonegotiateon trunks. Otherwise an attacker can pretend to be a switch and negotiate a trunk (switch spoofing). - Native VLAN: set the native VLAN on trunks to a VLAN with no devices (e.g. 999) and don’t use VLAN 1 for user traffic. This prevents double-tagging attacks.
- Unused ports: shut them down (
shutdown) and assign them to the unused VLAN. - DHCP snooping: blocks rogue DHCP servers; only ports towards the firewall and the server are marked as trusted.
- BPDU guard: stops an unauthorised switch plugged into an edge port from disrupting the network topology.
ip dhcp snooping
ip dhcp snooping vlan 30,40,50,99
interface GigabitEthernet1/0/48
ip dhcp snooping trust
! Unused ports
interface range GigabitEthernet1/0/30 - 44
switchport mode access
switchport access vlan 999
shutdown
Caution: if you use DHCP relay, the uplink port towards the relay agent must also be marked as trusted; otherwise DHCP snooping will block legitimate replies too. Apply changes in a maintenance window with console access ready.
7. Verification
! On the switch
show vlan brief
show interfaces trunk
show ip dhcp snooping binding
# From a Windows PC in the staff VLAN
ipconfig /all # 10.10.30.x address, gateway 10.10.30.1, DNS 10.10.20.10
Test-NetConnection 10.10.20.10 -Port 445 # file server: should be allowed
Test-NetConnection 10.10.50.30 -Port 554 # camera stream: should be blocked
tracert -d 10.10.20.10 # first hop should be the firewall
Also test from a phone on the guest network that internal IP addresses and the firewall’s management interface can’t be reached. Finally, save the switch configuration (copy running-config startup-config) and take a backup.
Conclusion
A good VLAN configuration has three parts: correctly assigned access and trunk ports, a separate zone with clear rules for each VLAN on the firewall, and switch security settings against layer 2 attacks. Once these are documented and tested, your network becomes both more secure and easier to manage. As part of our network solutions, SistemON plans VLAN migrations, carries them out outside working hours and documents them afterwards.
Frequently Asked Questions
Should inter-VLAN routing be done on the firewall or a layer 3 switch?
For SMEs the firewall is usually the right choice, because it can inspect inter-VLAN traffic at application and user level. If there is very high-volume traffic between servers and users, routing can be done on a layer 3 switch and restricted with access lists (ACLs), but ACLs don’t give the same level of inspection as a firewall.
Why should the native VLAN be an unused VLAN?
Untagged traffic arriving on a trunk port is placed in the native VLAN. If the native VLAN is one that users are on, VLAN hopping attacks such as double tagging become possible. Using a separate VLAN with no devices in it removes that risk.
Do devices with static IPs cause problems when moving to VLANs?
Yes, they are the most common source of trouble. The IP address, gateway and DNS settings of printers, cameras, recorders and some licence servers must be updated by hand for the new VLAN. Where possible, giving these devices DHCP reservations makes later changes much easier.
Need help with this?
Let us review your infrastructure free for the first month and share a clear list of risks and priorities.