Occasionally it is necessary to segment networks into VLANs (Virtual LAN). VLANs are a layer 2 technology which allow for segregation of broadcast domains. VLANs help to logically separate different types of traffic. Segmenting network traffic into data, VoIP, and/or Video Streams can help to provide better manageability and security. VLANs are typically applied at a network switch port by specifying the exact VLAN data and Voice traffic can use, but can also be specified at a Linux virtual port adapter and the network switch can enable 802.1q trunking.
This guide will help in setting up VLANs through editing of Linux configuration files.
The things you will need before starting:
- An understating of basic network configurations
- Access to a Debian-based Linux Desktop or Server
- Access to the root account or an account with sudo access.
- Basic knowledge of text editing software such as Vi, Vim, Nano, Pico, Gedit, etc.
Steps:
- Log in as either root or a user with sudo access.
- Install the vlan package
sudo apt-get install vlan
- Edit your the /etc/modules file to add the kernel module
8021q
to the last linesudo vi /etc/modules
- The location of the configuration file is /etc/network/interfaces
sudo vi /etc/network/interfaces
- Once the file is open, the document will look similar to this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp - We want to edit the configuration file to look more like this:
auto lo
(because the network adapter is called by name it is not necessary to specify)
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth0.2
iface eth0.2 inet dhcp
or
auto vlan2iface vlan2 inet dhcp
(it is necessary to specify which network adapter you want to apply this to because it is not already called out by name)
vlan-raw-device eth0 - Once the files have been edited, save, and restart the networking deamon
sudo /etc/init.d/networking restart
or reboot the desktop/serversudo reboot
You can now set static IP addressed manually to these VLAN adapters so that they do not rely on DHCP.