PCMCIA NIC で bonding

1. 余剰 NIC を有効活用すべく NIC 冗長を行う


私は ノートPC に Debian を導入して利用しているので あるが、この PC は基本的に 1日24時間365日 無休で動作させている
何せ Tower型PC は場所を取る上に電力消費が過多で しかも音がうるさい ので、寝ていると気に なって起きて しまったり隣人,隣室の耳と苦情を気に しなければ ならず、精神的に鬱屈してしまう
それを考えると ノートPC は本当に助かるが、惜しむらく は省電力機能に より余計な syspend が生じて勝手に御就寝なさったり HD への電源供給が切られて HD の寿命を縮めたり して くれる のには困るが…

HD が壊れた際には もう交換する しか対処手段が無いが、それ以外の箇所が壊れた時には何らかの手当て を して おきたい
具体的には ノートPC の onboard NIC が故障したり されると、何分 常時動作しているのが前提の Debian PC なもので通信出来く なって非常に困るので ある

# いや、onboard NIC が壊れると言う事態は仲々なかなかに起きないのでは あるが、以前に CASIO FIVA MPC-206VL と言う機器で NIC が壊れた事が ある...


と言うわけで bonding 機能を利用した NIC冗長を行いたい所で あるが、まるであつらえた状況の如く以下の NIC が余っていたり するので、これを有効活用する事と する

製品 : ELECOM LD-CBK/TX
interface : PCMCIA TypeII 32bit CardBus
速度 : 100BASE-TX
NIC chip : RTL8169sb/8110sb


対象 distribution は Debian 9.1 stretch を想定して いる



2. NIC を動作させて必要 package を導入


ず は この NIC を ノートPC にして動作するか どうか を確かめる

# dmesg [ 23.420620] r8169 0000:16:00.0 eth1: RTL8169sb/8110sb at 0xf82de000, xx:xx:xx:xx:xx:xx, XID 10000000 IRQ 16 [ 23.420623] r8169 0000:16:00.0 eth1: jumbo features [frames: 7152 bytes, tx checksumming: ok] [ 23.483176] r8169 0000:16:00.0 enp22s0: renamed from eth1 [ 25.303865] r8169 0000:16:00.0 enp22s0: link up

今の linux は eth1 と言う interface名が勝手に改称されてしまう もの らしい
いや、OS 起動時に eth0 と eth1 が揺れてしまって困っていたかつて の状況からすれば これは これで良いのかも知れないが、何となく釈然と しないもの が ある
よりに よって enp22s0 とは どう言う interface名なのか…良く分からん

# lsmod |grep 8169 r8169 73728 0 mii 16384 1 r8169

どうやら動作している らしい

Debian は license が厳しいので周辺機器を使用する際には firmware-misc-nonfree が別途 必要と なる事も ある

# これに該当する firmware が含まれなければ別の package を探す事に なるが、大体は これに含まれる


と言う訳で /etc/apt/sources.list を以下のように編集する

# deb http://ftp.jp.debian.org/debian/ stretch main contrib non-free deb http://ftp.jp.debian.org/debian stretch-updates main contrib non-free deb http://security.debian.org/ stretch/updates main contrib non-free

そして install

# apt-get install firmware-misc-nonfree

# 実は他の周辺機器で既に firmware-misc-nonfree を導入していたので、今回の NIC で firmware-misc-nonfree が必要で あったのか どうかは良く分からない


念のため、onboard NIC と PCMCIA NIC の MACアドレスを控えて おくと良いかも知れない

bonding 機能を利用するために以下の package を導入する

# apt-get install ifenslave-2.6



3. bonding 編入および動作確認


bonding module を常時一方使用(active-backup mode) で読み込む

# modprobe bonding mode=1

bonding module が読み込まれた事を確認して おく

# lsmod | grep bonding bonding 110909 0

指定された bonding mode が有効化されている事を確認

# cat /sys/class/net/bond0/bonding/mode
active-backup 1

bond0 が存在している事を確認

# ifconfig bond0

interface を落とす

# ifconfig enp22s0 down
# ifconfig eth0 down

eth0 を後回し に した方が良い らしい
後番 NIC よりも先に前番 NIC(つまり eth0) を down させたので あるが、すかさず以下が表示されて しまった

[3132220.502529] bonding: bond0: Warning: the permanent HWaddr of eth0 - xx:xx:xx:xx:xx:xx - is still in use by bond0 - set the HWaddr of eth0 to a different address to avoid conflicts

仮に bond0 に IP address を割り当てつつ 有効化し動作を試す

# ifconfig bond0 192.168.0.11 netmask 255.255.255.0 up

bond0 に対象 interface を編入

# ifenslave bond0 eth0 enp22s0

編入した interface を起こす

# ifconfig eth0 up
# ifconfig enp22s0 up

interface 状態が bond0:MASTER, eth0:SLAVE, enp22s0:SLAVE で ある事を確認して おく

# ifconfig bond0 bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500 inet 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255 # ifconfig eth0 eth0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500 # ifconfig enp22s0 enp22s0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500

bonding 状態を確認

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
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
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xx
Slave queue ID: 0

Slave Interface: enp22s0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xx:xx:xx:xx:xx:xx
Slave queue ID: 0

経路を追加する

# route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.1

IP packet を送受信可能か試す

# ping 192.168.0.1
# ping www.ocn.co.jp

ここまで正常に進めば、手作業での bonding 動作は成功している と見て良い



4. 自動起動時の設定


bonding.conf ファイルを新たに作って modprobe に bonding module を登録する

# cd /etc/modprobe.d/
# vi bonding.conf

alias bond0 bonding options bonding mode=1 miimon=100

自動読み込み module に bonding を登録

# cd /etc
# cp -p modules modules.org
# vi modules

bonding

interface 設定を編集

# cd /etc/network
# vi interfaces

# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet manual bond-master bond0 bond-primary enp22s0 allow-hotplug enp22s0 iface enp22s0 inet manual bond-master bond0 bond-primary enp22s0 auto bond0 iface bond0 inet static address 192.168.0.11 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1 # dns-* options are implemented by the resolvconf package, if installed # dns-nameservers xxx.xxx.xxx.xxx # dns-search xxx.xxx.xx bond_downdelay 200 bond_updelay 200

上記では bond-primary enp22s0 と しているが、通常は bond-primary eth0 を指定するかしくは指定行自体が不要で良い
ここでは優先的に PCMCIA NIC を使い潰して しまいたいので、敢えて この様な指定を行っている
要するに、余剰品の PCMCIA NIC に早く壊れて欲しい ので ある

なお、ここで以下の様に slaves 行を指定して OS を再起動させると、何故か interface が UP しない

auto bond0 iface bond0 inet static slaves eth0 enp22s0 bond_downdelay 200 bond_updelay 200

手動で ifconfig eth up すれば UP するので、OS 起動時の interface up script で bonding slave 制御を行って おり、明示的に記載してしまうと interface up script と conflict してしまう ので あろうと思う

OS を再起動して自動有効化される事を確認する

# shutdown -r now

OS 起動後、bonding 状態が Primary Slave: enp2s10 に変更されている事を確認

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: enp2s10 (primary_reselect always)
Currently Active Slave: enp2s10
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xx
Slave queue ID: 0

Slave Interface: enp22s0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xx
Slave queue ID: 0

どうやら正常に完了した らしい



5. interface 除外


interface を bonding から除外する際には以下を実行すれば良い らしい

# ifenslave -d bond0 enp2s10

# どう言った状況で使用するのか? 動作検証時?


公開 : 2017年8月16日
戻る
pagetop