=======================================================
Install the vlan package:
Code:
sudo apt-get install vlan
Code:
sudo modprobe 8021q
Code:
sudo sh -c 'grep -q 8021q /etc/modules || echo 8021q >> /etc/modules'
Code:
sudo vi /etc/network/interfaces
Code:
auto eth0.99 iface eth0.99 inet static address 192.168.99.1 netmask 255.255.255.0
Code:
sudo ifup eth0.99
goal: several vlan-interfaces on top of a bonding trunk
first step: create the bonding config
- 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
- in /etc/network/interfaces:
Code:
auto bond0.911 allow-hotplug bond0.911 iface bond0.911 inet static address 10.20.50.18 netmask 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
- 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
'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 is the last vlan interface and if so, shuts down bond0
bond0's post-down then will remove the kernel module
There might be routing issues. Beware of the order in /etc/network/interfaces.
댓글 없음:
댓글 쓰기