User Tools

Site Tools


VLAN: Configuring VLAN-tagging on CentOS 7 with Tux

Hey, my name is "Tux"! Did you ever wonder how you can pass tagged VLANs to your CentOS system?

Hey, my name is "Tux" and this tutorial will show you how you can pass tagged VLAN traffic directly to your CentOS system so the CentOS system itself will tag/de-tag the network data packages instead of the according physical/virtual switch.

First thoughts

Basic informations

In CentOS, VLAN interfaces are based on existing network interfaces.
Example: Let's say you want to configure a VLAN interface with a VLAN-ID of 100. In addition let's say one of the existing standard network interface on your CentOS system is called eth0 on which its top you want to set the VLAN to. This would mean that your new VLAN interface would be called eth0.100, which would be based on the existing eth0 interface. In this case, the eth0 interface would be the parent network interface while the eth0.100 interface would be the child network interface.

Start of tutorial

First it is necessary to load the kernel module 8021q into the kernel:

$ modprobe --first-time 8021q

To make sure whether the module has been loaded into the kernel, please execute the previous command again, which should return a similiar error message to:
modprobe: ERROR: could not insert '8021q': Module already in kernel


For more informations about the kernel module please execute:

$ modinfo 8021q

Now execute…

$ ifconfig

…to find out the according parent network interface name you want to configure the VLAN interface on top of, which sould return something similiar to:

Now inside the directory…
…open the according file called

$ vi ifcfg-<myParentNetworkInterface>

Comment out all content, except the following:


Save the file and quit the editor.
Now create a new file…

$ vi ifcfg-<myParentNetworkInterface>.<myVLANID>

(e.g. ifcfg-ens160.100)
…and add the following content:

DEVICE=<myParentNetworkInterface>.<myVLANID> (e.g. DEVICE=ens160.100)

Save the file and quit the editor.
Restart the network service:

$ systemctl restart network

Final note

It is also possible to configure multiple different VLAN child network interfaces on top of a single parent network interface!

End of tutorial

vlantaggingcentos.txt · Last modified: 2023/04/22