debian vlan



Debian VLAN notes

Install
# apt-get install vlan


Load the kernel module 8021q
# modprobe 8021q


Load 8021q in every boot
# echo 8021q >> /etc/modules


Add VLAN 40 to eth0 and configure eth0.40
# vconfig add eth0 40
Added VLAN with VID == 40 to IF -:eth0:-
# ifconfig eth0.40 192.0.2.8/25


Show eth0.40 configuration
# ifconfig eth0.4
eth0.40    Link encap:Ethernet  HWaddr 08:00:28:a8:b8:a7  
          inet addr:192.0.2.8  Bcast:192.0.2.127  Mask:255.255.255.128
          inet6 addr: fe80::a00:27ff:fea8:b8a7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:8642 (8.4 KiB)



proc
# cat /proc/net/vlan/config 
VLAN Dev name  | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
eth0.40         | 40 | eth0



#cat /proc/net/vlan/eth0.40
eth0.40  VID: 40   REORDER_HDR: 1  dev->priv_flags: 1
         total frames received         7570
          total bytes received      1553436
      Broadcast/Multicast Rcvd            0

      total frames transmitted         7732
       total bytes transmitted      7692798
Device: eth0
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0



Remove VLAN
# vconfig rem eth0.40
Removed VLAN -:eth0.40:-



Permanent Setups
Set VLAN at boot
Stub in /etc/network/interfaces
  

auto eth0.40
iface eth0.40 inet static
address 192.0.2.8
netmask 255.255.255.128
vlan-raw-device eth0


Add VLAN to Bridged Interface
auto br0.3
iface br0.3 inet static
        address 192.0.2.8
        netmask 255.255.255.128
        network 192.0.2.0
        broadcast 192.0.2.127
        pre-up vconfig add br0 3
        post-down vconfig rem br0.3





linux vlan