Linux: Configure an interface for a tagged vlan by ifconfig

Hi,

your linux box is connected to an ethernet switch where vlan tagging is configured (trunc) and you want to configure your network manually by ifconfig?

Load the module for tagged vlans 802.1q.

root@debdev ~# modprobe 8021q

Add the vlan to the interface. In this example VLAN ID 11 at Interface eth0

root@debdev ~# vconfig add eth0 11
Added VLAN with VID == 11 to IF -:eth0:-

Configure IP Address

root@debdev ~# ifconfig eth0.11 192.168.254.11 netmask 255.255.255.0 up

And add a (default) route if necessary

root@debdev ~# route add default gw 192.168.254.1

Or with ip command

root@debdev ~# ip link add link eth0 name eth0.11 type vlan id 11
root@debdev ~# ip link set eth0.11  up

Check

root@debdev ~# ip -d link show eth0.11

Set IP

root@debdev ~# ip a add 192.168.254.11/255.255.255.0 dev eth0.11

And delete

root@debdev ~#  ip link delete eth0.11

Leave a Reply Cancel reply