Configure VLAN under Linux (trunk, IEEE 802.1Q)

# install required package
apt-get install -y vlan

Configure VLAN / IP from CLI

ip link add link ens2f0 name ens2f0.36 type vlan id 36
ip l set dev ens2f0.36 up
 
# get IP per dhcp
dhclient -v ens2f0.36
 
# set static IP
ip a add 10.0.17.123/20 dev ens2f0.36
 
# tcpdump -nnei ens2f0.36 -vvv
 
# ip l delete ens2f0.36

Get VLAN configured on interface

cat /proc/net/vlan/*
 
ip -d link show dev eth0.100 | grep 'vlan protocol'

/etc/network/interfaces

auto lo
iface lo inet loopback
 
auto eth0
iface eth0 inet manual
 
auto br0
iface br0 inet static
    address 10.0.6.12
    netmask 255.255.255.0
    gateway 10.0.6.1
    dns-nameservers 10.0.0.100 10.0.1.101
    dns-search example.com
    dns-domain example.com
    bridge_ports eth0
 
 
# VLAN 10
auto vlan10
iface vlan10 inet manual
    vlan-raw-device br0
 
auto br10
iface br10 inet manual
    bridge_ports vlan10
 
 
# VLAN 22
auto vlan22
iface vlan22 inet manual
    vlan-raw-device br0
 
auto br22
iface br22 inet manual
    bridge_ports vlan22
    bridge_stp off
    bridge_maxwait 0
    bridge_fd 0
 
# remove vlan
vconfig rem vlan22

VLAN

# show VLANs
cat /proc/net/vlan/config
 
# old
# scan ip from mac
NET=192.168.0
for ((i=1; i<=254; i++));do
  ping -c 1 ${NET}.$i 2>&1 >/dev/null
  arp -a ${NET}.$i
done
 
NET=10.100.0
for ((i=200; i<=230; i++));do
    ping -c 1 ${NET}.$i 2>&1 > /dev/null || echo ${NET}.$i
done
 
# fix interface name
echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="02:01:02:03:04:05", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth0"' >> /etc/udev/rules.d/70-persistent-net.rules

Netplan
http://www.panticz.de/netplan

Links
http://www.microhowto.info/howto/configure_an_ethernet_interface_as_a_vlan_trunk_on_debian.html