802.1q VLAN interface configuration on Ubuntu 12.04 Desktop
Solution 1
Turns out there is no VLAN support in the ifupdown plugin that lets Network Manager work with /etc/network/interfaces, so instead we will have to manually add a keyfile for Network Manager.
First generate an UUID for the VLAN interface
root@kayna:~# uuidgen -r
5985c23f-2f9b-4e09-a33e-97505c79c78f
Then create the keyfile, here is an example for vlan id 200 on physical interface eth1
root@kayna:~# vi /etc/NetworkManager/system-connections/vlan200
[connection]
id=vlan200
type=vlan
uuid=5985c23f-2f9b-4e09-a33e-97505c79c78f
[vlan]
parent=eth1
id=200
[ipv6]
method=ignore
[ipv4]
method=auto
The interface will not show up in the GUI, but can be seen and managed with nmcli
root@kayna:~# nmcli dev
DEVICE TYPE STATE
eth1.200 vlan connected
eth0 802-3-ethernet disconnected
eth1 802-3-ethernet connected
Stop and start the interface with
root@kayna:~# nmcli con down id vlan200
root@kayna:~# nmcli con up id vlan200
Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/12
state: activated
Connection activated
The interface is created using the eth1.200 format, not the vlan200 format typically used in /etc/network/interfaces
root@kayna:~# ifconfig eth1.200
eth1.200 Link encap:Ethernet HWaddr c8:60:00:00:00:56
inet addr:192.168.1.46 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:185 errors:0 dropped:0 overruns:0 frame:0
TX packets:55 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:29811 (29.8 KB) TX bytes:9549 (9.5 KB)
Solution 2
Install VLAN package on your computer:
sudo apt-get install vlan
Edit your /etc/network/interfaces file so it would contain the following:
#The loopback network interface
auto lo
iface lo inet loopback
#This is a list of hotpluggable network interfaces. #They will be activated automatically by the hotplug subsystem.
auto vlan500
# VLAN 500
iface vlan500 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
network xxx.xxx.xxx.xxx
broadcast xxx.xxx.xxx.xxx
mtu 1500
vlan_raw_device eth0
Note: You have to replace my IP addresses, network masks and gateway IP address with your own.
3.Make sure that switch interface you are connected to configured with respective VLANs.
4.Restart your network interface:
sudo /etc/init.d/networking restart
You should see something like:
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 500 to IF -:eth0:-
Related videos on Youtube
Roy
Updated on September 18, 2022Comments
-
Roy almost 2 years
What is the correct way of configuring virtual LAN interfaces (hopefully without messing up Network Manager) on Ubuntu 12.04 Desktop?
Simply adding the interface to
/etc/network/interfaces
seems to cause Network Manager some confusion:auto vlan500 iface vlan500 inet static ... ... vlan_raw_device eth1
Is there a better way of doing it?
update:
I updated
/etc/NetworkManager/NetworkManager.conf
with ano-auto-default
clause, and setmanaged=false
in the[ifupdown]
section:[main] plugins=ifupdown,keyfile dns=dnsmasq no-auto-default=6C:FD:12:34:56:78, [ifupdown] managed=false
This keeps NetworkManager from firing up eth0, and makes it stay away from eth1 and it's VLAN interfaces. Previously it would only let a single VLAN interface be up, and it would put the static IP of that VLAN interface directly on the eth1 physical interface.
Still, there is a 2 minute delay during boot as (I presume) NetworkManager is trying to work out the network configuration.
Solution:
Solved by creating keyfiles as described in my answer below. My desktop now boots with all VLAN interfaces up and running, and without any delays during boot.
-
Roy over 11 yearsThat looks to be exactly how I've done it, but it seems to have the side effect of confusing NetworkManager and causing a two minute delay when booting.