debian on OpenblockのBonding-IFでvlan設定

投稿者: | 2011年5月22日
Pocket

対象サーバについて

製品名 OpenBlockS 600
OS(kernel ver) Debian lenny(2.6.29)
CPU 600MHz(AMCC PowerPC 405EX)
メモリ 1GB(DDR2 SDRAM)
ストレージ 8GB(Compact Flash)

はじめに

以下の図のようにOpenblocks600のeth0,eth1で束ねたbonding IF上にサブインタフェース(bond0.10、bond0.20)を作成します。

ちなみに対向装置のL2SW(Catalyst)では以下のような設定を行って試しました。

tag-vlanを通せるようにtrunkポートとしています。

interface FastEthernet0/7
 switchport trunk allowed vlan 10,20
 switchport mode trunk
!
interface FastEthernet0/8
 switchport trunk allowed vlan 10,20
 switchport mode trunk

インタフェース設定

以下のように設定ファイルを作成します。

close:~# cat /etc/network/interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback

auto bond0
iface bond0 inet manual
up /sbin/ifconfig bond0 0.0.0.0 up
slaves eth0 eth1

auto bond0.10
iface bond0.10 inet static
 address 172.16.0.1
 netmask 255.255.255.0
 network 172.16.0.0
 broadcast 172.16.0.255
 vlan-raw-device bond0

auto bond0.20
iface bond0.20 inet static
 address 10.0.0.1
 netmask 255.255.255.0
 network 10.0.0.0
 broadcast 10.0.0.255
 vlan-raw-device bond0

close:~# shutdown -r now

再起動が終了したら、一度networkを落としてみます。

close:~# /etc/init.d/networking stop

Deconfiguring network interfaces...bonding: bond0: Warning: the permanent HWaddr of eth0 - 00:0a:85:04:02:ff - is still in use by bond0. Set the HWaddr of eth0 to a different address to avoid conflicts.

エラーが出ました。こちらによると、私の環境ではbond0のMACアドレス=eth0のMACアドレスになっているので、bond0のMACアドレスであるeth0を最後に落とせということのようです。

つまり、現状IFダウン時にeth0、eth1の順番で落としているところを、eth1、eth0の順番に落とすようにしないといけないようです。

上記サイトでは二つ解決方法が載っており、一つ目の方法であるeth1のMACをbond0に割り当てることでエラーを止めようと考え、/etc/network/interfacesにhwaddress ether 00:0a:85:04:82:ff(eth1のMACアドレス)を設定してみることにしました。bond0のMACアドレス=eth1のMACアドレスであれば、確かにeth0、eth1で落とすことで解決しそうです。

hwaddressを指定するためには、manual設定で0.0.0.0割り当てでなく、static設定にしてIPアドレスをダミー設定する必要がありますので、適当に1.1.1.1を振っておきます。

close:~# cat /etc/network/interfaces
...

auto bond0
iface bond0 inet static
 hwaddress ether 00:0a:85:04:82:ff
 address 1.1.1.1
 netmask 255.255.255.0
 network 1.1.1.0
 broadcast 1.1.1.255
slaves eth0 eth1

以下、省略

上記で再起動をかけましたが、bond0のMACアドレスはeth0のままでした。

/etc/udev/rules.d/70-persistent-net.rulesでBOND0のMACアドレスを修正することも可能かもしれませんが、IFアサインが不安定になると嫌なので今回は試しませんでした。

一度staticをmanualに書き換え、bond0にアドレスを割り当てない設定に戻します。

close:~# cat /etc/network/interfaces
...

auto bond0
iface bond0 inet manual
up /sbin/ifconfig bond0 0.0.0.0 up
slaves eth0 eth1

以下、省略

次に、先ほどのサイトで紹介されていたもう一つの解決方法である、起動時と停止時でIFのUP/DOWN順序を反転させる方法を確かめてみました。

まずはifenslaveコマンドで、IFの起動順序によりエラーが出ているのかを検証します。

IF起動(1回目):eth0→eth1

close:~# ifenslave bond0 eth0 eth1
device bond0 left promiscuous mode
eth0: link is up, 100 FDX
bonding: bond0: making interface eth0 the new active one.
bonding: bond0: first active interface up!
bonding: bond0: enslaving eth0 as an active interface with an up link.
eth1: link is up, 100 FDX
bonding: bond0: enslaving eth1 as a backup interface with an up link.

上記順序で立ち上げると、bond0のMACアドレスはeth0のMACアドレスになりました。

IF停止(1回目):eth1→eth0

close:~# ifenslave -d bond0 eth1 eth0
bonding: bond0: releasing backup interface eth1
bonding: bond0: releasing active interface eth0
bonding: bond0: Warning: clearing HW address of bond0 while it still has VLANs.
bonding: bond0: When re-adding slaves, make sure the bond's HW address matches its VLANs'.

落とす際には、eth1 eth0と指定しました。起動時と順序を反転させたためエラーは出ません。想定通りの動きです。

続いて、起動時と停止時でIF指定順序を同じにした場合を試します。

これまで、起動も停止もeth0→eth1の流れで実施してエラーが出ることは見てきましたので、eth1→eth0の順序で試してみます。

IF起動(2回目):eth1→eth0

close:~# ifenslave bond0 eth1 eth0
device bond0 entered promiscuous mode
eth1: link is up, 100 FDX
bonding: bond0: making interface eth1 the new active one.
device eth1 entered promiscuous mode
bonding: bond0: first active interface up!
bonding: bond0: enslaving eth1 as an active interface with an up link.
eth0: link is up, 100 FDX
bonding: bond0: making interface eth0 the new active one.
device eth1 left promiscuous mode
device eth0 entered promiscuous mode
bonding: bond0: enslaving eth0 as an active interface with an up link.

起動はできました。また、bond0のMACアドレスがeth1のMACアドレスになっていました。

IF停止(2回目):eth1→eth0

close:~# ifenslave -d bond0 eth1 eth0
bonding: bond0: Warning: the permanent HWaddr of eth1 - 00:0a:85:04:82:ff - is still in use by bond0. Set the HWaddr of eth1 to a different address to avoid conflicts.
bonding: bond0: releasing backup interface eth1
bonding: bond0: releasing active interface eth0
device eth0 left promiscuous mode
bonding: bond0: Warning: clearing HW address of bond0 while it still has VLANs.
bonding: bond0: When re-adding slaves, make sure the bond's HW address matches its VLANs'.

先ほどと同じエラーが表示されました。bond0のMACアドレス=eth1のMACアドレスのためです。

上記の確認の結果、立ち上げ時と停止時で順序を入れ替えるのが必須であることは分かりましたが、/etc/network/interfacesで必須となる「slaves ethX ethY」設定では起動時も停止時もethX → ethYの順になってしまうため、必ずエラーが出てしまいます。

そこで、インタフェース設定でどうにかできないか試してみました。

close:~# vi /etc/network/interfaces
slaves eth0 eth1
up /sbin/ifenslave bond0 eth0 eth1
down /sbin/ifenslave -d bond0 eth1 eth0

slavesを消してup/downコマンドを追加してみましたが、slaves設定は必須のため立ち上がりませんでした。

close:~# vi /etc/network/interfaces
slaves eth0 eth1
up /sbin/ifenslave bond0 eth0 eth1
down /sbin/ifenslave -d bond0 eth1 eth0

ではslavesを残したままup/down設定したらどうかというと、bonding化の処理が二重に走るためエラーが増えてしまいます。

そこで、ifenslaveのスクリプトを修正して、停止時の順序のみを引っくり返したいと思います。

close:~# vi /etc/network/if-post-down.d/ifenslave
...

if [ -n "$INTERFACES" ] ; then
                ifconfig "$IFACE" up
                for slave in $INTERFACES ; do
                for slave in eth1 eth0 ; do
                        $IFENSLAVE --detach "$IFACE" "$slave"
                done
                ifconfig "$IFACE" down
fi

$INTERFACESをeth1 eth0と直に書いてしまいました。OPENBLOCKS600ではUSB-NICを使わない限りは増設できないため直に書きましたが、通常のPC/サーバであればIFアサインが変わる可能性もありますので、もう少し汎用性のある書き方をした方が良いと思います。

上記設定でネットワークの起動、再起動が問題なく行えるようになったか、試してみます。

ネットワーク停止時の確認

close:~# /etc/init.d/networking stop
Deconfiguring network interfaces...bonding: bond0: releasing backup interface eth1
bonding: bond0: releasing active interface eth0
bonding: bond0: Warning: clearing HW address of bond0 while it still has VLANs.
bonding: bond0: When re-adding slaves, make sure the bond's HW address matches its VLANs'.
Removed VLAN -:bond0.10:-
Removed VLAN -:bond0.20:-
done.

ネットワーク起動時の確認

close:~# /etc/init.d/networking start
Configuring network interfaces...ADDRCONF(NETDEV_UP): bond0: link is not ready
eth0: link is up, 100 FDX
bonding: bond0: making interface eth0 the new active one.
bonding: bond0: first active interface up!
bonding: bond0: enslaving eth0 as an active interface with an up link.
ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
eth1: link is up, 100 FDX
bonding: bond0: enslaving eth1 as a backup interface with an up link.
if-up.d/mountnfs[bond0]: waiting for interface bond0.10 before doing NFS mounts (warning).
if-up.d/mountnfs[bond0]: waiting for interface bond0.20 before doing NFS mounts (warning).
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 10 to IF -:bond0:-
if-up.d/mountnfs[bond0.10]: waiting for interface bond0.20 before doing NFS mounts (warning).
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 20 to IF -:bond0:-
done.

正常に停止、起動が行えました。

ちなみに

if-up.d/mountnfs[bond0]: waiting for interface bond0.10 before doing NFS mounts (warning).
if-up.d/mountnfs[bond0]: waiting for interface bond0.20 before doing NFS mounts (warning).
if-up.d/mountnfs[bond0.10]: waiting for interface bond0.20 before doing NFS mounts (warning).

というwarningが出ていますが、こちらを参考にすると気にしなくてよさそうです。

Pocket

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です