Thursday 7 November 2013

VLAN's on linux

A quick search for VLAN setup on Linux brings up a few old docs which suggest the use of the 'vconfig' utility. But these days one can use the very versatile 'ip' command as explained here. For example one can create a VLAN interface on the eth0 hardware interface with VLAN ID 2 like this:
sudo ip link add link eth0 name eth0.2 type vlan id 2
One can assign an address to the interface like a normal interface:
sudo ip addr add 192.168.2.2/24 dev eth0.2
And to delete the address:
sudo ip link del dev vlan0  type vlan id 2
To show list full details of the interfaces (including VLAN id):
ip -d link