La forma más conocida de configurar una VLAN en Linux es la de copiar el fichero de configuración de la interfaz y añadir/cambiar ciertos parámetros, ejemplo en RHEL asumiendo el ID 80 para la VLAN:
# cp -p /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.80
# vim /etc/sysconfig/network-scripts/ifcfg-eth0.80
# Añadimos:
VLAN=yes
# Cambiamos el dispositivo:
DEVICE=eth0.80
# /etc/init.d/network restart
El comando vconfig nos simplifica un poco la tarea de gestionar una o varias VLAN. Para el ejemplo anterior, sería tan sencillo como:
# vconfig add eth0 80 Added VLAN with VID == 80 to IF -:eth0:-
Ya tenemos la interfaz creada:
# ifconfig eth0.80
eth0.80 Link encap:Ethernet HWaddr 08:00:27:E7:48:CC
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Podemos ver información detallada sobre ella en /proc/net/vlan/:
# cat /proc/net/vlan/eth0.80
eth0.80 VID: 80 REORDER_HDR: 1 dev->priv_flags: 1
total frames received 0
total bytes received 0
Broadcast/Multicast Rcvd 0
total frames transmitted 0
total bytes transmitted 0
total headroom inc 0
total encap on xmit 0
Device: eth0
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
EGRESS priority mappings:
Podríamos asignarle la IP con el comando ifconfig:
# ifconfig eth0.80 192.168.1.222 netmask 255.255.255.0
Y si quisiéramos eliminar la interfaz:
# ifconfig eth0.80 down && vconfig rem eth0.80
Recordad que tiene que estar cargado en el kernel el módulo 8021q:
# lsmod | grep 8021q 8021q 19491 0 garp 5901 1 8021q
En fin, ¡para gustos los colores!