Ubuntu to configure the VLAN function--official website VLAN How to

Source: Internet
Author: User
Tags egrep

http://ubuntuforums.org/showthread.php?t=703387

Introduction to Ubuntu website

802.1q VLAN HOWTO Doing 802.1q trunking to a Ethernet switch is really easy. I describe two methods-a text only one for servers, and a GUI one for desktops.

The VLAN number that is interface uses always gets appended to the physical after a dot, so for interface a instance Rface eth0 using VLAN number would be called eth0.99. The instructions below all assume your want to connect to VLAN 99-change the number as required.

Server Console method
Install the VLAN package:
Code:

sudo apt-get install VLAN
Load the 8021q kernel module:
Code:
sudo modprobe 8021q
Ensure that this module gets loaded over a reboot by adding to/etc/modules:
Code:
sudo  sh-c ' grep-q 8021q/etc/modules | |-echo 8021q >>/etc/modules '
Configure the interface by editing/etc/network/interfaces:
Code:
sudo nano/etc/network/interfaces
And adding a stanza like this:
Code:
Auto eth0.99
iface eth0.99 inet static address
192.168.99.1 netmask 255.255.255.0
Then bring the interface up:
Code:
sudo ifup eth0.99
Desktop GUI method
Install the VLANPackage using Synaptic:system->administration->synaptic Package Manager
and search for and install the package 8021q.

The next bit has to is done by the command line.
Load the 8021q kernel module:
Code:
sudo modprobe 8021q
Ensure that this module gets loaded over a reboot by adding to/etc/modules:
Code:
sudo  sh-c ' grep-q 8021q/etc/modules | |-echo 8021q >>/etc/modules '
Now we have to create a low-level interface The network manager can:
Code:
Vconfig Add eth0 99
Now we can find eth0.99 in the GUI system->administration0>network and configure it how we want. ADV Reply February 9th, 2009 #2 sador42 a Cup of Ubuntu Join Date Feb 2009 Beans 1 re:802.1q VLAN HOWTOUsing the above method, which are the best way to add a permanent route add statement so I can route some over one VLAN and some over another? ADV Reply May 5th, 2009 #3 Tmeller a Cup of Ubuntu Join Date Feb 2008 Beans 2 re:802.1q VLAN HOWTORecently, we needed to configure channel bonding on VLANs.
The internet did not supply us with infos and so we did it as a best-effort.

This is a howto to Debian etch, but should also work on Ubuntu 7.x+:

Goal:several vlan-interfaces on a bonding trunk

The bonding config for the step:create

-In/etc/network/interfaces:
Code:
#auto bond0
iface bond0 inet manual pre-up
	IP link set bond0 up/up
	ifenslave bond0 eth0 up
	ifenslave bond0 eth1
	post-down ifenslave-d bond0 eth0 eth1 post-down modprobe-  R bond0
Second step:define the logical network link (repeat as to your needs)

-In/etc/network/interfaces:

Code:
Auto bond0.911
 allow-hotplug bond0.911
 iface bond0.911 inet static address
	10.20.50.18
	255.255.255.192
	Network 10.20.50.0
	broadcast 10.20.50.63
	Gateway 10.20.50.2
	pre-up/etc/network/ Bondingstate up bond0 911
	post-down/etc/network/bondingstate down Bond0 911
Third step:glue them together

-In/etc/network/bondingstate:
Code:
# script/etc/network/bondingstate #
wird aufgerufen aus/etc/network/interfaces
# 04.09.2007, no copyright
#
 
# variablen setzen

set-x
change_state=$1
trunk=$2 vlanid=$3 case

$CHANGE _state in Up
  )
    #egrep "$TRUNK"/etc/network/run/ifstate >/dev/null 2>&1
    if [!-f/proc/net/bonding/$TRUNK]; then
      Ifup $TRUNK
      If [$-ne 0]; then
        exit 1
      fi
    fi
    vconfig add $TRUNK $VLANID
    ;;

  Down)
    vconfig rem $TRUNK. $VLANID
    egrep "$TRUNK \.[ 0-9]+ "/etc/network/run/ifstate >/dev/null 2>&1
    if [$-ne 0]; then
      if [-Z" $VLANID]; then
  
   exit 0
      Else
        ifdown $TRUNK
      fi
    fi
    ;;
Esac
  
What happens:

' Auto bond0.911 ' starts setting up the interface.
' Pre-up ' calls Bondingstate
Bondingstate tests whether the bonding module is loaded,
Then starts bonding, if need be.
' Iface bond0 ' enslaves the physical NICs, then returns success
Bondingstate adds the given VLAN ID and returns success
' Auto bond0.911 ' configures ip-addresses and returns success

Configuring additional links is but a copy of ' bond0.911 '

On shutdown, ' post-down/etc/network/bondingstate down bond0 911 '
Calls Bondingstate, which in turn checks In/etc/network/run/ifstate
Whether this are the last VLANs interface and if so, shuts down bond0
Bond0 ' s Post-down then'll remove the kernel module

There might be routing issues. Beware of the order in/etc/network/interfaces.

Hope This might is helpful for anyone, anytime

Have Fun,
Your Swiss Telekom hackers
Best before end:09/2007 last edited by Tmeller; May 5th, 2009 at 02:44 PM.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.