Configure VLAN on Linux server

27 || 0  || 2018-04-18 07:46:16 || root || || Bash

Commands for configuring VLAN on Linux server for the following cases:

  1. When port is tagged
  2. When port is untagged

# Configure VLAN for tagged port
modprobe 8021q
vconfig add eth0 333
ifconfig eth0.333 up
ifconfig eth0.333 10.20.30.40 netmask 255.255.255.0

# Configure VLAN for untagged port
ip addr add 10.20.30.40/24 dev eth0
ip route add 10.20.30.39/32 via 10.20.30.40 dev eth0