802.1q is a standard that supports VLAN tagging on an ethernet network.
This article will explain how to configure a switchport on a Cisco switch
for vlan tagging, as well as how to configure an Ubuntu linux server for 802.1q
(vlan) tagging.
Cisco Setup
All I am doing here is trunking one interface (G2/0/18) and restricting access to two vlans (101 and 102).
Linux Setup
Add the 8021q module to the kernel
Add the module to the /etc/modules file, so that it loads at next startup
Install the appropriate package
Configure the network. In my example, eth0 is connected to the trunk port on a Cisco switch, with vlans 101 and 102 trunked. eth1 is connected to a separate network and switch.
Restart networking. I came across inconsistent results by using /etc/init.d/networking restart and the ifup and ifdown commands. While your mileage may vary, I just rebooted the box.
Make sure things are working. As you can see, eth0 does not have an ip address, while the vlan interfaces, eth0.101 and eth0.102, do.
Issues
I ran into an issue where when connecting to an interface that did not have a gateway defined (eth0.102), the packet was being dropped by the kernel. To fix this, the following two lines were needed in /etc/sysctl.conf:
Kyle Johnson
A hapless technoweenie with a penchant for power lifting, heavy metal,
Linux, automation, IoT, and learning. From and living in Baltimore, MD.