■前回行った設定の検証
Squeezeでアクティブ/バックアップモードのbonding(teaming)を設定す
http://d.hatena.ne.jp/labunix/20121005
実はeth0は100Mbps、eth1は1000MbpsのNICを使用している。
⇒100Mbpsで動作していることを確認。
「arp_interval」と「arp_ip_target」の設定が効いていなかった代わりに
「bond-miimon 100」による「MII Polling Interval (ms): 100」が動作していた。
⇒「bond_arp_interval」と「bond_arp_ip_target」とするか、
コメントアウトしてMII監視にする。
「bond-primary」指定を「eth0」とした。
⇒表記が「None」でなくなった。
リアルタイム監視方法
⇒「mii-tool」、「ethtool」、「ifconfig」で行える。
「mii-tool」にはwatchオプション「-w」がある。
「ethtool」、「ifconfig」はスクリプトを書いた。
WOLの設定
⇒Lennyと同様、「rc.local」に記述した。
Debian Lenny をWOL起動する
http://d.hatena.ne.jp/labunix/20110612
■以下に設定変更。
auto bond0
iface bond0 inet static
address 192.168.188.188
netmask 255.255.255.0
gateway 192.168.188.254
broadcast 192.168.188.255
bond-slaves eth0 eth1
bond-mode 1
bond-miimon 100
bond-primary eth0
bond_arp_interval 15000
bond_arp_ip_target 192.168.188.254
bond-downdelay 200
bond-updelay 200
■「Bonding Mode」ほか、パラメータの確認。
※HW addrを隠すsed行は実際には不要。
「bond_arp_interval」と「bond_arp_ip_target」有効
$ cat /proc/net/bonding/bond0 | \
sed s/"\(HW addr\:\).*"/"\1 [eth0 Mac Address]"/g
Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
ARP Polling Interval (ms): 15000
ARP IP target/s (n.n.n.n form): 192.168.188.254
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: [eth0 Mac Address]
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: [eth0 Mac Address]
■ARPチェック
※デフォルトは15秒に1回。設定した場合は設定値(ミリ秒単位)の通りであることを確認。
$ sudo tcpdump arp -i bond0 -n
01:46:23.448728 ARP, Reply 192.168.188.254 is-at 00:XX:XX:XX:XX:XX, length 46
01:46:38.448741 ARP, Reply 192.168.188.254 is-at 00:XX:XX:XX:XX:XX, length 46
■以下に設定変更。
auto bond0
iface bond0 inet static
address 192.168.188.188
netmask 255.255.255.0
gateway 192.168.188.254
broadcast 192.168.188.255
bond-slaves eth0 eth1
bond-mode 1
bond-miimon 100
bond-primary eth0
bond-downdelay 200
bond-updelay 200
■ARPチェック
※ARPパケットが流れなくなった。
$ sudo tcpdump arp -i bond0 -n
■「Bonding Mode」ほか、パラメータの確認。
「bond_arp_interval」と「bond_arp_ip_target」を無効
※コメントアウト
$ cat /proc/net/bonding/bond0 | \
sed s/"\(HW addr\:\).*"/"\1 [eth0 Mac Address]"/g
Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: [eth0 Mac Address]
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: [eth0 Mac Address]
■「mii-tool」
$ sudo mii-tool
eth0: negotiated 100baseTx-FD, link ok
eth1: negotiated 100baseTx-FD flow-control, link ok
■「ethtool」コマンドのNICの検出(Link detected)と速度。
$ sudo ethtool bond0 | grep "Speed\|Link detected"
Link detected: yes
$ sudo ethtool eth0 | grep "Speed\|Link detected"
Speed: 100Mb/s
Link detected: yes
$ sudo ethtool eth1 | grep "Speed\|Link detected"
Speed: 100Mb/s
Link detected: yes
■「ifconfig」コマンドの「MASTER」または「SLAVE」。
※HWaddrを隠すsed行は実際には不要。
$ env LANG=C /sbin/ifconfig | grep "^eth\|^bond\|MASTER\|SLAVE" | \
sed s/"\(HWaddr \).*"/"\1 [eth0 Mac Address]"/g
bond0 Link encap:Ethernet HWaddr [eth0 Mac Address]
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
eth0 Link encap:Ethernet HWaddr [eth0 Mac Address]
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr [eth0 Mac Address]
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
■「ip」コマンドの「MASTER」または「SLAVE」と、「state UP」
$ ip addr show dev bond0 | grep "^[0-9]\:" | awk -F\: '{print $3}' | sed s/">"/"&\n"/
<BROADCAST,MULTICAST,MASTER,UP,LOWER_UP>
mtu 1500 qdisc noqueue state UP
$ ip addr show dev eth0 | grep "^[0-9]\:" | awk -F\: '{print $3}' | sed s/">"/"&\n"/
<BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP>
mtu 1500 qdisc mq master bond0 state UP qlen 1000
$ ip addr show dev eth1 | grep "^[0-9]\:" | awk -F\: '{print $3}' | sed s/">"/"&\n"/
<BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP>
mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
■リアルタイム監視(mii-tool)
eth1を抜き差し、eth0を抜き差し。
$ sudo mii-tool -w
02:12:40 eth0: negotiated 100baseTx-FD, link ok
02:12:40 eth1: negotiated 100baseTx-FD flow-control, link ok
02:12:50 eth1: no link
02:12:54 eth1: negotiated 100baseTx-FD flow-control, link ok
02:12:58 eth0: no link
02:13:01 eth0: negotiated 100baseTx-FD, link ok
■リアルタイム監視(ethtool)
eth1を抜き差し、eth0を抜き差し。
※最新の分しか表示されない。1秒だと速過ぎる。
$ sudo watch -d -n 2 ' \
ethtool bond0; \
echo -n "eth0 ";ethtool eth0 | grep "Link detected"; \
echo -n "eth1 ";ethtool eth1 | grep "Link detected"; \
'
■「...」は変化なし。「tee」にも渡しやすい。
ethtool bond0;
echo -n "eth0";ethtool eth0 | grep "Link detected";
echo -n "eth1";ethtool eth1 | grep "Link detected";
sleep 1; done
Settings for bond0:
Link detected: yes
eth0 Link detected: yes
eth1 Link detected: yes
...
Settings for bond0:
Link detected: yes
eth0 Link detected: yes
eth1 Link detected: no
...
Settings for bond0:
Link detected: yes
eth0 Link detected: yes
eth1 Link detected: yes
...
Settings for bond0:
Link detected: yes
eth0 Link detected: no
eth1 Link detected: yes
...
Settings for bond0:
Link detected: yes
eth0 Link detected: yes
eth1 Link detected: yes
■ifconfigを使う
※リンクダウン時に「RUNNING」が消えます。
$ watch -d -n 1 '
env LANG=C /sbin/ifconfig | grep "^eth\|^bond\|MASTER\|SLAVE" | sed s/"Link*.*\| MULTICAST .*\|.*BROADCAST"//g
'
■変化を見るには以下とする。
env LANG=C /sbin/ifconfig | \
grep "^eth\|^bond\|MASTER\|SLAVE" | \
sed s/"Link*.*\| MULTICAST .*\|.*BROADCAST"//g | \
xargs echo -n | \
sed s/" "/","/g | \
sed s/"^"/"`env LANG=C date -u`,"/g; \
echo ""; \
sleep 1 ;
done
Sat Oct 6 18:02:30 UTC 2012,bond0,RUNNING,MASTER,eth0,RUNNING,SLAVE,eth1,RUNNING,SLAVE
...
Sat Oct 6 18:02:48 UTC 2012,bond0,RUNNING,MASTER,eth0,RUNNING,SLAVE,eth1,SLAVE
...
Sat Oct 6 18:03:01 UTC 2012,bond0,RUNNING,MASTER,eth0,RUNNING,SLAVE,eth1,RUNNING,SLAVE
...
Sat Oct 6 18:03:21 UTC 2012,bond0,RUNNING,MASTER,eth0,SLAVE,eth1,RUNNING,SLAVE
...
Sat Oct 6 18:03:32 UTC 2012,bond0,RUNNING,MASTER,eth0,RUNNING,SLAVE,eth1,RUNNING,SLAVE
■「ip」コマンドの場合
■UP/DOWNチェック
$ while true ; do \
env LANG=C date '+%Y/%m/%d %H:%M:%S:%N';
ip addr | grep state | \
sed s/"\: <.*state\| qlen.*\|^[0-9]\: "//g | \
grep -v "lo\|vmnet" | \
sed s/" "/"\t"/g;
sleep 1;
done
2012/10/07 21:57:27:708661636
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:28:735232152
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:29:761817950
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:30:787997955
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:31:814564795
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:32:841191791
eth1 DOWN
eth0 UP
bond0 UP
2012/10/07 21:57:33:867785829
eth1 DOWN
eth0 UP
bond0 UP
2012/10/07 21:57:34:894579460
eth1 DOWN
eth0 UP
bond0 UP
2012/10/07 21:57:35:921309056
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:36:947749256
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:37:974379052
eth1 UP
eth0 UP
bond0 UP
2012/10/07 21:57:39:002016427
eth1 UP
eth0 DOWN
bond0 UP
2012/10/07 21:57:40:028205833
eth1 UP
eth0 DOWN
bond0 UP
2012/10/07 21:57:41:055061383
eth1 UP
eth0 DOWN
bond0 UP
2012/10/07 21:57:42:081495225
eth1 UP
eth0 DOWN
bond0 UP
2012/10/07 21:57:43:107870906
eth1 UP
eth0 UP
bond0 UP