.altsieben

a linux sysadmin code collection

VLAN With Debian

in our company infrastructure we use several defined VLAN to separate network segments.
For example we don’t want to communicate our backup over the normal line.

The following describes - in an ultra short form - the way to realize this topic.

As a reminder, under Debian you configure your network settings under /etc/network/interfaces.

regular network settings

auto eth0
iface eth0 inet static
address 172.27.x.y
netmask 255.255.252.0
network 172.27.x.0
broadcast 172.27.x.255
gateway 172.27.x.254

dns-nameservers 1.2.3.4
dns-search DOMAIN

You have to fit it to your environment.

alias settings

to use alias IP adresses you extend your interface with an .1 and so on. It look like this

auto eth0:1
iface eth0:1 inet static
address 172.28.x.y
netmask 255.255.0.0

use of vlan

so, aliases are cool to configure a second IP to your system. But if you want use VLANs, you need a similarly config.

First of all install an extra debian package.

crocodile:~# dpkg -l |grep vlan
ii  vlan	1.9-3	i386	user mode programs to enable VLANs on your ethernet devices ...

after installation with apt-get you configure it also under /etc/network/interfaces.

auto eth0.360
iface eth0.360 inet static
address 10.172.x.y
netmask 255.255.255.0
network 10.172.x.0
broadcast 10.172.x.255
vlan_raw_device eth0

You have to setup your adapted VLAN ID(s) to your config.

to check your new config restart your network and … et voilà.

crocodile:~# ifconfig
eth3    Link encap:Ethernet  HWaddr 00:1b:fc
	    inet addr:172.27.x.y  Bcast:172.27.x.255  Mask:255.255.252.0
    	...

eth3.360  Link encap:Ethernet  HWaddr 00:1b:fc  
      	inet addr:10.172.x.y  Bcast:10.172.x.255  Mask:255.255.255.0
      	...