Date created: 03/15/20 11:39:23. Last modified: 08/30/21 09:42:03

VLAN Interfaces

Old Style / vconfig

# Setup:
$sudo apt-get install vconfig
$sudo modprobe 8021q
$vconfig add eth0 2
$sudo ip addr add 192.168.58.34/27 dev eth0.2
$sudo ip link set up eth0.2
# Remove:
$sudo vconfig rem eth0.2

 

New Style / iproute3

# Setup:
$sudo ip link add link eth0 name eth0.2 type vlan id 2
$sudo ip a a 192.168.58.34/27 brd 192.168.58.63 dev eth0.2
$sudo ip link set dev eth0.2 up
$ip -d link show eth0.2
# Remove:
$sudo ip link set dev eth0.2 down
$sudo link delete eth0.2

 

Debian/Ubuntu Persistent Config

#/etc/network/interfaces
auto eth0.2
iface eth0.2 inet dhcp
vlan-raw-device eth0
iface eth0.2 inet6 auto
vlan-raw-device eth0