Configuring VLANs in Ubuntu

Install the Vlan package:

sudo apt-get install vlan

Download the Vlan module (802.1q):

sudo modprobe 8021q

We make it to load automatically when the system starts:

sudo  sh -c 'grep -q 8021q /etc/modules || echo 8021q >> /etc/modules'

We edit the configuration file for the network interfaces /etc/network/interfaces eg the nano editor:

sudo nano /etc/network/interfaces

Add a VLAN interface to it:

auto eth0.5
iface eth0.5 inet static

We start the prescribed network interface:

sudo ifup eth0.5

Let’s look at the parameters:

sudo cat /proc/net/vlan/config

VLAN interface can be called differently, for example:
VLAN_PLUS_VID (vlan0005)
DEV_PLUS_VID (eth0.0005)

You can change the name type like this:

/sbin/vconfig set_name_type VLAN_PLUS_VID_NO_PAD

An example of adding a VLAN interface:

/sbin/vconfig add eth0 5
/sbin/ifconfig vlan5 up

If the VLAN interface is running as vlan5, then in /etc/network/interfaces we specify:

auto vlan5
iface vlan5 inet static
vlan_raw_device eth0

See also:
Adding vlan to Ubuntu for ABillS
Configuring the Network in Linux

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a comment

Leave a Reply