Penguin

VLANs under Linux are fairly trivial to set up. You’ll need to make sure your switch is passing VLAN-tagged frames to you.

There are some VLAN tools you’ll need – on a Debian-based system, apt-get install vlan will fix you up. 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

These commands 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(8).

Note that you’ll probably have to stop using the raw physical device. 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 interface name zero-padded to four digits, eg: eth0.1 or eth0.0001, vlan1 or vlan0001.

Note: you cannot mix differing formats within the same machine (even using one form in interface and a different form from some other configuration system).

Read the vlan-interfaces ManPage for more information.


Part of CategoryNetworking