VLAN tagging allows logical network segmentation over shared physical network infrastructure — relevant on a VPS when your provider supports VLAN-based private networking. This guide covers configuring VLAN interfaces on Linux.
When VLAN Tagging Is Relevant on a VPS
Some VPS providers offer private networking based on VLANs, where your traffic on a specific VLAN ID is isolated from other customers sharing the same physical network infrastructure — check whether your specific provider's private networking offering uses this model before pursuing manual VLAN configuration.
Understanding VLAN Tagging Basics
A VLAN tag (802.1Q) is inserted into Ethernet frames, identifying which logical network segment traffic belongs to — switches and routers that understand VLAN tagging can then correctly isolate/route traffic based on this tag, even over shared physical infrastructure.
Installing VLAN Support
sudo apt install vlan -y
sudo modprobe 8021q
echo "8021q" | sudo tee -a /etc/modules
Creating a VLAN Interface
sudo ip link add link eth0 name eth0.100 type vlan id 100
Creates a virtual interface (eth0.100) tagged with VLAN ID 100, layered on top of the physical eth0 interface.
Assigning an IP Address to the VLAN Interface
sudo ip addr add 192.168.100.10/24 dev eth0.100
sudo ip link set eth0.100 up
Making the VLAN Configuration Persistent (Netplan Example)
network:
version: 2
vlans:
eth0.100:
id: 100
link: eth0
addresses: [192.168.100.10/24]
sudo netplan apply
See general Ubuntu network configuration approaches — ensure your VLAN configuration survives reboots by configuring it through your distribution's persistent network configuration system, not just ad-hoc ip commands.
Using VLAN Tagging for Network Segmentation
See How to Set Up Network Segmentation on a Single VPS for related segmentation concepts — VLAN tagging is one mechanism for achieving genuine network-level isolation, particularly relevant if your provider's private networking specifically requires VLAN awareness rather than a simpler flat private network.
Verifying VLAN Connectivity
ping 192.168.100.1
Test connectivity to other resources on the same VLAN, confirming your tagged interface is genuinely functioning correctly.
Checking Configured VLANs
cat /proc/net/vlan/config
Common Errors
VLAN interface created but no connectivity — verify your VPS provider's underlying network infrastructure actually supports/expects the specific VLAN ID you've configured; a mismatch between your configuration and the provider's actual network setup is the most common cause of this issue.
Continue Reading
- How to Set Up Network Segmentation on a Single VPS
- How to Configure Multiple Network Interfaces on a VPS
- How to Configure Static Routes on a Linux VPS
Browse more articles in Advanced Networking & VPN.