Our task is to learn how to configure a network card in Debian to work with tagged traffic. That is, to learn how to configure VLANs on network interfaces.
First, make sure you have the vlan package installed:
# dpkg --list | grep vlan
ii vlan 1.9-3 user mode programs to enable VLANs on your ethernet devices
If not, install it:
# aptitude install vlan
For VLANs to be set up on reboot - they need to be written into the file
/etc/network/interfaces
For example, here's a sample of such a file:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.250
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 127.0.0.1
auto vlan333
iface vlan333 inet static
address 10.0.1.2
netmask 255.255.255.0
vlan_raw_device eth0
auto eth0.999
iface eth0.999 inet static
address 10.100.10.3
netmask 255.255.255.0
vlan_raw_device eth0
auto eth0.100
iface eth0.100 inet static
address 192.168.1.1
netmask 255.255.255.0
vlan_raw_device eth0
Here you can see 3 VLANs declared. Both the vlan333 notation and the eth0.999-style notation are valid. The difference is only in their interface naming. I prefer the eth.XXX form, which immediately gives me information about which interface the VLAN sits on. However, the vlanX form isn't without its advantages - the name of such an interface is more convenient to specify in various systems, for example in a firewall - if the underlying interface changes, the name vlanX won't change, meaning you won't need to rewrite all the configs referencing that name.
Also, the vlan_raw_device option was added, telling the system which network card this VLAN will be tagged on.
During operation, VLANs can be managed via the vconfig utility. For example:
# vconfig add eth0 777
This command will add VLAN=777 to the eth0 interface.
# vconfig rem vlan777
And this command - deletes the VLAN vlan777.
Comments