I am capturing packets through sockets. While reading those captured packets, i realized that, somehow VLAN tags are removed. After surfing on internet, i read something about stripping of VLAN tag by linux distros itself. Anybody want to shed some light here?


Usually 802.1q tagging is not needed for network clients, just for switches and inter switch/router/firewall configurations, so this is not something enabled by default in the Linux world. But of course you can setup a Linux server as a firewall or to do routing for example so in these cases you want to keep tagged packets so the switches know where to send the traffic coming out of your Linux server.

Ubuntu needs a device and drivers that are vlan, 802.1q aware. You need to install the userspace tool vlan to be able to enable the configuration that your interface(s).

sudo apt-get install vlan

You then need to load the module:

sudo modprobe 8021q

You then need to add your physical interface to a vlan interface (which will create a new sub interface to the vlan):

sudo vconfig add eth1 10

Then finally create an ip address for the sub interface:

sudo ip addr add dev eth1.10

If you want to make this permanent:

Add the module to the kernel on boot:

sudo su -c 'echo "8021q" >> /etc/modules'

Then create a stanza in /etc/networking/interfaces:

auto eth1.10
iface eth1.10 inet static
    vlan-raw-device eth1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.