Tuesday, July 17, 2007 at 9:37 am by Brady Wilson

802.1q VLAN Tagging on FreeBSD 6.2

VLAN tagging allows a single network interface to access multiple networks at the same time. The multiple VLANs are presented as individual “virtual” NICs to the operating system. Each virtual NIC can have its own IP configuration.

VLAN tagging is useful when your server needs to connect to multiple networks but has a limited number of physical network adapters, or when the physical adapters are “trunked” into a single interface for speed or redundancy.

The underlying protocol is 802.1q and the server operating system, network adapter and the connected switch must support the protocol. There is other functionality within 802.1q but here we are only concerned with VLAN tagging.

The switch port(s) connected must also be configured for VLAN tagging. I will not go into switch configuration or VLAN theory and planning here.

Although I did not test it, IPv6 settings should work as well when applied to the VLANs.

————————————————————-

Manual settings

The VLAN interfaces can be turned up and configured manually at the command line.

Create the VLANs:

# ifconfig vlan_device vlan vlan_id vlandev parent_device

vlan_device is a number you assign to the interface.
vlan_id is the VLAN number to use that is configured on the connected switch.
parent_device is the physical interface name this VLAN is running on.

Example

# ifconfig vlan0 vlan 101 vlandev fxp0

Assign IP settings:

# ifconfig vlan_device ip address netmask netmask

Example

# ifconfig vlan0 10.20.30.1 netmask 255.255.255.0

An ifconfig vlan0 or an ifconfig –a will now show a vlan0 interface with the assigned IP settings.

Remove:

# ifconfig vlan0 destroy

————————————————————-

Permanent settings

The following configurations will allow the VLANs to be setup at server boot time.

1.) Edit /etc/rc.conf

The cloned_interfaces parameter will create the desired VLAN interfaces:

cloned_interfaces=”vlan20 vlan30″

Add ifconfig lines for each vlan device:

ifconfig_vlan20=”inet 192.168.0.3 netmask 255.255.255.0 vlan 20 vlandev fxp0″
ifconfig_vlan30=”inet 172.17.16.3 netmask 255.255.255.0 vlan 30 vlandev fxp0″

If the physical interface will not have its own IP address assigned, bring it up explicitly:

ifconfig_fxp0=”up”

2.) Reboot the server to verify your configurations work at boot time.

————————————————————-

Notes:

– Whether configured manually or at boot time you should see a kernel module loaded for VLAN operation.

kldstat returns a list of loaded modules. You should see if_vlan.koin the list when using VLANs.

– It is good practice to avoid using VLAN ID 1 anywhere as it is usually reserved as the Primary/Native VLAN on switches.

– Not all NICs support 802.1Q VLANs - look for VLAN_MTU and VLAN_HWTAGGING options for your NIC in ifconfig. man vlan provides further info. I found though that my adapter (bce0) was not listed in man vlan but it did support the necessary options and worked with VLAN tagging.

————————————————————-

Older versions of FreeBSD

Older versions of FreeBSD may not load the kernel module automatically. In these cases you will need to modify your kernel to enable the VLAN tagging functionality.

To compile this driver into the kernel, place the following lines in your kernel configuration file:

device miibus
device vlan

- or add something like the following line to add the vlan devices directly into the kernel

pseudo-device vlan 2 # IEEE 802.1Q VLAN Support

Alternatively, to load the driver as a module at boot time, place the following line in loader.conf (/boot/loader.conf):

if_vlan_load=”YES”

Note: I did not test these kernel settings on older versions of FreeBSD myself. This was gleaned from other sources on the Internet.

Article Topics

Related Article:
Virtualized for Non-Profit

July 1, 2008

Opus Interactive has virtualized 22 of their servers in a effort to upgrade internal systems.  Instead of trying to sell the servers, or reprovision them, Opus Interactive decided the best thing to do is to donate them to Omni Media Networks Inc.  The donated servers were needed in an effort to expand Omni Media Networks Internet outreach programs.  Opus Interactive is very [...]

Leave a Comment

You must be logged in to post a comment.

Article Archives:

  • Virtualized for Non-Profit

    Opus Interactive has virtualized 22 of their servers in a effort to upgrade internal systems.  Instead of trying to sell the servers, or reprovision them, Opus Interactive decided the best thing to do is to donate them to Omni Media Networks Inc.  The donated servers were needed in an effort to expand Omni Media Networks Internet outreach programs.  Opus Interactive is very [...]

    July 1st, 2008

  • If a tree gets planted in the forest will anyone hear?

    Opus Interactive has joined with Arbor Day Foundation in their mission to “…inspire people to plant, nurture and celebrate trees.”  Arbor Day Foundation is the largest nonprofit tree-planting organization, with nearly one million members and averages over 12 million trees planted each year.
    So with that, the question becomes with almost 12 million trees each year, why [...]

    June 16th, 2008

  • Protecting the minds and hearts of our children with OpenDNS

    There is no argument that there is a lot of crap on the Internet.  And I am not referring to poorly designed web sites, time wasting games and an overabundance of news about absolutely everything.  The deep, dark alleys of the Internet (and sometimes not all that far removed) are filled with pornography, crime, drugs, [...]

    June 9th, 2008

  • Interop Las Vegas 08 Photo Journal

    Interop Las Vegas 08 . The adventures over the course of 5 days.  Below you will see somethings you wish you didn’t and other you are glad to see. Enjoy.
    Arrived at the MGM Grand Hotel Checked in Room #4136.  Look at that view.

    Well what would Vegas be like without a little gambling?  Eric at his first slot [...]

    May 22nd, 2008

  • Smokeping on FreeBSD 7

    This write-up assumes a working copy of FreeBSD 7.0.  It was built using 7.0-RELEASE.  It should work on FreeBSD 6.x-STABLE and future versions of FreeBSD 7.  The package versions listed were current as of this writing but may have been updated by the time someone uses this howto.
    This is a basic setup of Smokeping.  There [...]

    April 24th, 2008

  • Installing MySQL4 and MySQL5 on a single FreeBSD 6.2 Server.

    This write-up makes the following assumptions:

    Working copy of FreeBSD 6.2.
    Build: 6.2-RELEASE.

    Which should work on 6.2-STABLE and 7.0 as well.
    Please let me know if you run into typos or other technical issues when implementing this.

    Download the latest binaries from mysql.com.
    At write-up time this was:
    mysql-5.0.45-freebsd6.0-i386.tar.gz
    mysql-standard-4.1.22-unknown-freebsd6.0-i386.tar.gz
    Install MySQL 4.
    Uncompress the binary source.
    # cd /usr/local
    # gunzip < [...]

    March 11th, 2008

Article Comments:

0 Comments