Monday, July 25, 2005

Bikin VLAN di Linux

# VLAN installation & Configuration on the Linux Side.


I have:

* Linux kernel 2.2.14
* Vlan 0.0.10 Patched into it
* Cisco Catalyst 2900XL
* 3Com 3C509B NIC using patched driver 3c59x


Currently VLAN is not part of the kernel distribution so you need to patch
it into a supported Linux kernel and re-compile.

You need the kernel source. If you don't have it already, you can get from
ftp.kernel.org or from one of its mirrors. If this scares you, read the
KERNEL-HOWTO.

It is assumed that you have the linux kernel source extracted, and found at:
$HOME/linux If your setup is different, then some of these commands may
need to be slightly different.

Download the VLAN package from the vlan homepage and extract it's contents.
tar -xvzf vlan*.tar.gz

Go to the vlan directory, build the vlan tools by just typing:
make

After this you get a programm named . This program manages all VLAN
specific configurations.

Now patch the kernel.
Go to the linux directory
cd linux
(if you installed the kernel source from some rpm based distribution it is
something like /usr/src/linux)
patch the kernel by typing:

patch -p 1 < $HOME/vlan/vlan.patch (patch is in the vlan directory)

Time to compile your kernel. Use the make menuconfig command in your
linux directory to select your kernel options. The option related to
802.1Q VLANs is found under the Networking options.

Additional help for kernel compilation can be found in KERNEL-HOWTO

Assuming your kernel compiled cleanly, you are now ready to use it.
Install your kernel in the normal manner (fix up your /etc/lilo.conf file
appropriately and run lilo as root.)
Reboot your computer and choose your new kernel.

As your computer comes back to life, there will be little sign that you are
now 802.1Q capable.
You should see something like this:

802.1Q VLAN Support v0.10 Ben Greear
vlan Initialization complete.


Your system is now vlan ready, lets configure some vlans:
I'm assuming that your VLAN capable network card is eth0.

First, set the eth0 state to down:

ifconfig eth0 down

Ben's Note: Regarding the next section, you can run plain ethernet and VLAN over the same NIC, but you may not want to..

Whatever your previous netconf was, you should move everything to vlans.
This means, that you don't set ip address to the real interface, but set it to
vlan interface. To set your eth0 with no ip:

ifconfig eth0 0.0.0.0 up

!note!
YOU MUST SET THE ETH0 TO UP, or it wont work. (ifconfig eth0 up)

Add some vlans; goto your vlan directory where you previously compiled
vconfig and type:

vconfig add eth0 2

! Little note about VLAN 1. In Cisco systems it is the default VLAN
so you MUST start using vlans from 2.

This will create device vlan0002 to your system. Linux will think, that it
is just another network device, so you can configure it like any other. Also
you should see the interface by typing

ifconfig -a

Lets make some conf on the vlan then:
ifconfig -i vlan0002 10.0.231.1 broadcast 10.0.231.0 netmask 255.255.255.0 up

This ends the configuration at the linux side.

# Specific Extreme Networks Configuration

From: Craig Metz: cmetz@inner.net

Extreme configuration example:

create vlan v42
config vlan v42 tag 42
config vlan v42 add port 10 tagged

... will create a vlan named v42, whose 802.1Q tag is 42, and connect port
10 (tag 42) to that vlan.

Cisco-specific configuration

Cisco Conf
configure the port you want to use as the trunk:

telnet switch or use the console port

ena
(will prompt for password, so have it ready)

conf t
interface FastEthernet0/24 (it doesnt have to be 0/24)
duplex full
speed 100
switchport trunk encapsulation dot1q
switchport trunk allowed vlan 2
switchport mode trunk


This conf will do the following:

Set the port to full duplex mode; force the port to 100Mb mode; set the port
vlan encapsulation to support 802.1Q; tell the
switch that the port is allowed to run vlans through (even if you set just
VLAN 2, cisco will automatically add VLAN 1 and VLAN 1002-1005) to the port
and set the port to trunk mode aswell. Trunk mode tells the switch that
a number of VLANS can go through it.

Last line is usually the mother of all screw-ups. If you forget that, you
won't get your VLAN working. Simple as that.

Now configure some other port to be used as the destination for the vlan:

conf t
interface FastEthernet0/1
duplex half
speed 10
switchport access vlan 2
end

Here we tell the switch to force the port 1 to half duplex 10Mb mode (normal
10 Mb NIC) and only traffic from interface VLAN 2 can go through this port.
also you can use a number of ports with VLAN 2, like a HUB ;)

You should now connect some other device to port 1.

Let it have an ip of eg. 10.0.231.2 mask 255.255.255.0

Ping linux from it

ping 10.0.231.1

If it replies scream: "YESS!!" This means, that VLAN is working.

Hard truth: It's not over, till its over.
if this works, then you are out of the woods, if not, well I hear that
tcpdump is a good tool ;-) and tcpdump that came with the vlan package even
better tool. (if you want to dump, use the one that came with vlan package)

NOTE: Ethereal also supports VLANs, and is much more beautiful than tcpdump, if you have GUI capabilities.

If you can ping the linux and from linux the host, you should try the
following at linux side:

ping -s 1476 10.0.231.2

If there is no reply, there is something foggy with the NIC. and you
should start debugging. If ping -s 100 10.0.231.2 works, then it is most likely
an MTU problem with your NIC/Driver.
Cisco-specific configuration

Cisco Conf
configure the port you want to use as the trunk:

telnet switch or use the console port

ena
(will prompt for password, so have it ready)

conf t
interface FastEthernet0/24 (it doesnt have to be 0/24)
duplex full
speed 100
switchport trunk encapsulation dot1q
switchport trunk allowed vlan 2
switchport mode trunk


This conf will do the following:

Set the port to full duplex mode; force the port to 100Mb mode; set the port
vlan encapsulation to support 802.1Q; tell the
switch that the port is allowed to run vlans through (even if you set just
VLAN 2, cisco will automatically add VLAN 1 and VLAN 1002-1005) to the port
and set the port to trunk mode aswell. Trunk mode tells the switch that
a number of VLANS can go through it.

Last line is usually the mother of all screw-ups. If you forget that, you
won't get your VLAN working. Simple as that.

Now configure some other port to be used as the destination for the vlan:

conf t
interface FastEthernet0/1
duplex half
speed 10
switchport access vlan 2
end

Here we tell the switch to force the port 1 to half duplex 10Mb mode (normal
10 Mb NIC) and only traffic from interface VLAN 2 can go through this port.
also you can use a number of ports with VLAN 2, like a HUB ;)

You should now connect some other device to port 1.

Let it have an ip of eg. 10.0.231.2 mask 255.255.255.0

Ping linux from it

ping 10.0.231.1

If it replies scream: "YESS!!" This means, that VLAN is working.

Hard truth: It's not over, till its over.
if this works, then you are out of the woods, if not, well I hear that
tcpdump is a good tool ;-) and tcpdump that came with the vlan package even
better tool. (if you want to dump, use the one that came with vlan package)

NOTE: Ethereal also supports VLANs, and is much more beautiful than tcpdump, if you have GUI capabilities.

If you can ping the linux and from linux the host, you should try the
following at linux side:

ping -s 1476 10.0.231.2

If there is no reply, there is something foggy with the NIC. and you
should start debugging. If ping -s 100 10.0.231.2 works, then it is most likely
an MTU problem with your NIC/Driver.