Thursday, October 18, 2012

Ubuntu VLAN Setup

Here is a quick example on how to add a VLAN interface in Ubuntu (12.04). Make sure you have the right package installed.
sudo apt-get install vlan
First test your configuration from the command line.
# modprobe 8021q
# vconfig add eth0 100
# dhclient eth0.100
Or if you are using a bridge for Virtual Machines.
# modprobe 8021q
# vconfig add br0 100
# dhclient br0.100
Then make your changes permanent by editing /etc/network/interfaces. Make sure to add 8021q to /etc/modules
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# add home network VLAN 100
auto eth0.100
iface eth0.100 inet dhcp

# remove the default route to the new VLAN
up route del default dev eth0.100
Then execute
sudo invoke-rc.d networking restart
Make sure you have physical access to the machine so that if something goes wrong you can still change your network settings.

I had an issue where DHCP would assign a second default gateway to my VLAN interface. This caused issues with my network setup. My solution was to remove the new default route after the interface was up. I added this code to the end of my interface file.

up route del default dev eth0.100
You can verify that the route is removed with "route -n".

No comments:

Post a Comment