VLAN Configuration¶
Create VLAN tagged sub-interfaces to communicate with hosts on a VLAN network using Linux (Kali).
Everything on this page is only relevant if connected to a trunk port.
VLAN 8021q kernel module¶
This should autoload anyway with
ip link add
Will fail if any VLAN links exist; delete VLAN sub-interfaces first.
Network Interface Discovery¶
VLAN tag traffic¶
This avoids accidental traffic leakage on an untagged network since only the sub-interfaces will have an IP once VLANs are configured.
sudo ip link add link eth0 name eth0.100 type vlan id 100
sudo ip link set eth0 up
sudo ip link set eth0.100 up
DHCP Configuration¶
Configure the VLAN sub-interface to obtain an IP using DHCP. If the VLAN network does not use DHCP then a static IP must be configured
Receive an IP from the DHCP server on the network which handles the specified VLAN.
The IP will be in the range associated by the DHCP with the VLAN tag #.
Use when disconnecting/tearing down or before renewing.
This only gives up the lease so other hosts can use the IP.
Static IP Configuration¶
Configure a static IP on the VLAN sub-interface.
sudo ip addr add 192.168.100.10/24 dev eth0.100
sudo ip addr replace 192.168.100.10/24 dev eth0.100
Verifying Configuration¶
Target the gateway on the VLAN or some other known live host.
ip route get <known_host_ip>
Target the gateway on the VLAN or some other known live host.
Removing VLAN Interfaces¶
ip -o -d link show type vlan | awk -F': ' '{print $2}' | cut -d@ -f1 | xargs -r -n1 sudo ip link delete dev
Persistent Configuration¶
Persist VLAN configuration across reboots.