VLAN Tagging allows an individual IP Address to be configured as part of multiple VLANs.
The steps below tag VLAN ID 1002 on the eth0 interface. Replace eth0 with the name of your own network interface (you can list the interfaces with ip a) and 1002 with your VLAN ID.
1- Firstly, install the vlan package on Ubuntu with the command below.
apt-get install vlan
2- Then load the 802.1Q kernel module.
sudo modprobe 8021q
3- Make the module load automatically after a reboot by running the following command.
sudo su -c 'echo "8021q" >> /etc/modules'
4- Add the VLAN 1002 interface to /etc/network/interfaces and add the line “vlan-raw-device eth0” at the bottom, as in the example below.
auto eth0.1002
iface eth0.1002 inet static
address <VLAN IP address>
netmask <VLAN netmask>
vlan-raw-device eth0
Note: Logsign manages the network configuration with ifupdown (the networking service). Netplan is removed during the installation, so the configuration file is always /etc/network/interfaces. This file also includes /etc/network/interfaces.d/*, so you can put the VLAN definition into a separate file under that directory if you prefer.
5- Bring up the new VLAN interface to complete the process.
sudo ifup eth0.1002