Penguin
Note: You are viewing an old revision of this page. View the current version.

VLANs under linux are fairly trivial to set up. There are some vlan tools you'll need ('apt-get install vlan' on a Debian based system).

You'll need to make sure your switch is passing vlan-tagged frames to you.

Once you have the tools installed, you can add a vlan to a physical interface with the vconfig command:

 vconfig add eth0 1234
 vconfig add eth0 2000

Will add two vlans, 1234 and 2000, to the physical eth0 device, and create two new interfaces, eth0.1234 and eth0.2000. These interfaces still need to be configured with ifconfig.

Note that you'll probably have to stop using the raw physical device, and just use the vlan interfaces.

VLANs and Debian's interfaces file

Debian has some fairly nice integration with the vlan tools. You have a choice of methods to use:

This one will work out which ethernet device you are using based on the stub of the device name. Don't get it confused with an aliased ip address though!

auto eth0.1234
iface eth0.1234 inet dhcp

This one renames the interface to something easier to read, but you need to specify which ethernet device you are using:

auto vlan1234
iface vlan1234 inet dhcp
      vlan-raw-device eth0

Both formats also have an option to have the vlan zero-padded to four digits, eg: eth0.1 or eth0.0001, vlan1 or vlan0001.

Read the vlan-interfaces manpage for more information