A small company’s network usually starts out as one big, flat network: the office computers, the printer, the guest Wi-Fi, the server and the camera system are all in the same IP range, on the same switch. This works until someone connects an infected laptop to the guest network and it reaches the accounting file server. The solution is a VLAN: it lets you create several separate logical networks on a single physical switch. In this article, we explain what a VLAN is, how it works, and how we usually set it up in a small business network and on a Proxmox server.
What is a VLAN?
A VLAN (Virtual Local Area Network) is a layer 2, Ethernet-level broadcast domain that is defined by the switch configuration rather than by the cabling. Devices in one VLAN can’t see another VLAN directly: broadcast traffic, such as ARP and DHCP requests, doesn’t cross over, and only a router or firewall can forward traffic between two VLANs – and there you can control what gets through.
In practice, it’s the same as if each group of devices had its own switch and its own cabling, only cheaper and more flexible: moving a port to another network takes a few clicks in the switch interface.
802.1Q: how does the switch mark the frames?
The standard for VLANs is IEEE 802.1Q. When an Ethernet frame has to reach another device while keeping track of which VLAN it belongs to, the switch inserts a 4-byte tag into it after the source MAC address:
| Field | Size | Purpose |
|---|---|---|
| TPID | 16 bits | Always 0x8100; it indicates a tagged frame |
| PCP | 3 bits | Priority (0–7), for QoS, for example for VoIP traffic |
| DEI | 1 bit | Marks a frame that can be dropped first under congestion |
| VID | 12 bits | The VLAN identifier |
The 12-bit VID gives 4,096 values, of which 0 and 4095 are reserved, so you can use IDs from 1 to 4094. Because of the tag, a frame can be up to 1,522 bytes instead of the usual 1,518; today’s switches and network cards handle this without any trouble.
Access and trunk ports
Switch ports have two basic modes:
- Access (untagged) port: belongs to a single VLAN. The device connected to it – an office PC, a printer – knows nothing about VLANs and sends plain Ethernet frames; the switch adds and removes the tag.
- Trunk (tagged) port: carries the traffic of several VLANs over a single cable, with the frames carrying an 802.1Q tag. Ports like this connect switches to each other, the switch to the router or firewall, Wi-Fi access points (where each SSID is a VLAN) and virtualisation servers.
One VLAN can travel untagged on a trunk port: this is the native VLAN (PVID with some vendors). Out of the box, this is almost always VLAN 1. The terms vary by vendor – Cisco says “access” and “trunk” port, many other vendors say “untagged” and “tagged” membership – but the idea is the same.
A typical VLAN layout at a small company
For an office of 10–50 people, this layout is a proven starting point:
| VLAN | Name | What goes in it? |
|---|---|---|
| 10 | Office | Workstations, laptops, internal Wi-Fi |
| 20 | Servers | File server, application servers, virtual machines |
| 30 | VoIP | IP phones; voice traffic gets priority |
| 40 | Printers, IoT | Printers, cameras, access control system |
| 50 | Guest | Guest Wi-Fi; it only reaches the internet |
| 99 | Management | Switches, access points, hypervisors, IPMI/iDRAC/iLO |
The IDs can be chosen freely; what matters is the principle: each group of devices goes into its own VLAN, and the firewall controls the traffic between the VLANs. The guest network can only reach the internet, the office computers can reach the servers only on the ports they need, and only the sysadmins’ machines can reach the management VLAN. The servers’ remote management interfaces (IPMI, iDRAC, iLO) are especially important: they have no place on the office network or on the internet, because they often run old, rarely updated firmware.
If some of your machines run in the cloud, the role of VLANs is taken over there by virtual networks (VPCs) and subnets, and remote access is best handled without open ports – we wrote about this in our article on AWS Session Manager.
VLANs on a Proxmox VE server
A virtualisation server usually runs virtual machines belonging to several VLANs: the file server in the server VLAN, a mail gateway (as in our Proxmox Mail Gateway installation) in a DMZ, and the host’s own interface in the management VLAN. This doesn’t need a separate network card per VLAN: a trunk port on the switch and a VLAN-aware Linux bridge on the host are enough.
In the /etc/network/interfaces file of Proxmox VE 7, it looks like this, with the host’s management address in VLAN 99:
auto lo
iface lo inet loopback
iface eno1 inet manual
auto vmbr0
iface vmbr0 inet manual
bridge-ports eno1
bridge-stp off
bridge-fd 0
bridge-vlan-aware yes
bridge-vids 2-4094
auto vmbr0.99
iface vmbr0.99 inet static
address 192.168.99.10/24
gateway 192.168.99.1
You can set the same thing up in the web interface: in the node’s System → Network menu, turn on the VLAN aware option on the bridge. After that, for each virtual machine’s network card, you set which VLAN it belongs to in the VLAN Tag field; in the machine’s configuration this appears as net0: virtio=…,bridge=vmbr0,tag=20. The guest operating system doesn’t need to know about the VLAN; the bridge does the tagging. If a virtual machine – a virtual firewall, for example – needs to see several VLANs, leaving the tag field empty gives it the traffic as a trunk, and the VLAN interfaces have to be created inside the guest.
Proxmox VE 7 uses ifupdown2 by default, so you can apply changes without a reboot, with the ifreload -a command or the Apply Configuration button in the interface. With the older, non-VLAN-aware method, separate eno1.20 and vmbr0v20 devices are created for each VLAN, which quickly becomes hard to follow, so for a new installation the VLAN-aware bridge is the better choice.
Common mistakes
- You lock yourself out of the host. If you move the management IP to a VLAN but the trunk isn’t configured on the switch port yet, you lose the connection. Configure the switch first, and have IPMI or an on-site console at hand.
- A different native VLAN on the two ends of a trunk. In this case, untagged traffic ends up in the wrong network. It should be the same on both sides, and no production traffic should run on it.
- Everything stays in VLAN 1. Out of the box, switches put every port in VLAN 1. It’s worth moving the management interface and the real traffic out of it, and disabling unused ports. If user ports aren’t in the trunks’ native VLAN, VLAN hopping attacks based on double tagging don’t work either.
- The trunk lets every VLAN through. On trunk ports, only allow the VLANs that are really needed there.
- Routing between VLANs allows everything. If the router forwards traffic between the VLANs without rules, the segmentation is only for show. The rules have to be written on the firewall, with a default-deny policy.
- There is no documentation. A table of the VLAN IDs, the IP ranges and what is on which switch port saves many hours of troubleshooting.
In summary
A VLAN is a simple and cheap tool for making sure a small company’s network isn’t one big space that anyone can roam. It doesn’t need expensive equipment: managed switches and most small business firewalls support 802.1Q, and Proxmox VE handles it out of the box. If you plan the segmentation for a time when you are working on the network anyway – during a move, as with the Google Workspace migration, or when setting up a new server – there is much less disruption.
We help with planning network segmentation and with configuring switches and virtualisation servers; you can read about our operations services on the Infrastructure and operations page.