Daily tip

How to add a VLAN ID to a network interface?

First check if the the kernel module 8021q is loaded with

$lsmod | grep 8021q

if it is not loaded, load the relative module with

#modprobe 8021q

Then either

vconfig add IF VLAN_ID


ip add link IF name IF.VLAN_ID type vlan id VLAN_ID

Where IF is the network card interface: eth0, eth1, ens33, etc.

And VLAN_ID is the ID of your VLAN

For example if the VLAN ID is 5 and the ethernet interface is eth1, you can either run

#vconfig add eth1 50


#ip add link eth1 name eth1.5 type vlan id 5

You must be root or have the appropriate root permissions.