Date created: Sunday, March 15, 2020 11:39:23 AM. Last modified: Sunday, September 8, 2024 12:10:58 PM

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 / iproute2

# 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