差分

ナビゲーションに移動 検索に移動

LANの多重化

2,823 バイト追加, 2019年9月10日 (火) 14:36
編集の要約なし
'''自宅の環境で試しましたが…USB-LANアダプタはBonding出来ないようです…<br/>でも…オンボードのr8152もUSB-LANなんだけどな…'''
 
 
ArchLinuxのカーネルがバージョンアップしてから、またLANが不安定に…。<br/>
ちなみに使用しているNICはasixのAX88179チップのやつ…。<br/>
※以下の手順はセキュリティ上VirtualBoxで操作した内容になっています。
 == bondingの準備 ===== ifenslaveのインストール ===bondingに必要な「ifenslave」パッケージを、以下のコマンドでインストールします。<syntaxhighlight lang="bash">pacman -S ifenslave</syntaxhighlight>
netctlはデフォルトでインストールされているので、netctlを使用したbondingを実現できるように設定ファイルを作成します。
=== netctlの設定 ===
先ずは、bondingするNIC名を以下のコマンドで取得します。
<syntaxhighlight lang="bash">ip a</syntaxhighlight>
inet6 fe80::3092:89f5:4be1:eb66/64 scope link
valid_lft forever preferred_lft forever
3: enp0s9enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:59:5c:9a brd ff:ff:ff:ff:ff:ff
inet 10.0.4.15/24 brd 10.0.4.255 scope global dynamic noprefixroute enp0s9
valid_lft forever preferred_lft forever</syntaxhighlight>
現時点ではNetworkManagerが起動しているので、2つのNICが生きています。<br/>
上記の例では「enp0s3」と「enp0s9」が、それぞれのNIC名になります。上記の例では「enp0s3」と「enp0s8」が、それぞれのNIC名になります。
次に手順に従って、サンプルファイルをコピーします。
#Mode=balance-rr</syntaxhighlight>
【修正後】
<syntaxhighlight lang="text" line="line" highlight="4,6,7,8-10">Description="A bonded interface"
Interface=bond0
Connection=bond
BindsToInterfaces=(enp0s3 enp0s9enp0s8)
IP=static
Address="10192.0168.256.1511/24"Gateway='192.168.56.1'DNS=('192.168.56.1')
IP6=stateless
Mode=active-backupprimary=enp0s3</syntaxhighlight>
「BindsToInterfaces」はbondingの対象にするNIC名を指定します。<br/>
「Address」は固定IPv4アドレスを指定します。<br/>
「IP6=stateless」はIPv6を有効にして、おまかせしています。<br/>
「Mode」は動作させるモードを指定します。指定する内容は[http://nosa.cocolog-nifty.com/sanonosa/2013/12/linuxnicbonding.html こちら]を参照してください。<br/>
「primary」は優先させるNICを指定します。
= サービスの切り替え == bondingドライバの設定 ===次にbondingドライバの設定をしていきます。<br/>今の状態で動作させてもMIIの監視間隔が0なので、切り替わりません。<br/>nano等のエディタで「/etc/modprobe.d/bonding.conf」を以下の内容で新規作成します。<syntaxhighlight lang="text" line="line">options bonding miimon=100 primary=enp0s3</syntaxhighlight> == 切り替え ===== NetworkManegerの無効化とnetctlの有効化 ===
NetworkManegerを無効化して、netctlを有効化します。
<syntaxhighlight lang="bash">systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl netctl start bondingnetctlenable bonding</syntaxhighlight> === 再起動 ===bondingドライバに設定を反映させるために、OSを再起動します。<syntaxhighlight lang="bash">reboot</syntaxhighlight> === 動作確認 ===以下のコマンドで動作状況を確認します。<syntaxhighlight lang="bash">cat /proc/net/bonding/bond0</syntaxhighlight>以下の様に表示されます。<syntaxhighlight lang="text">Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup)Primary Slave: NoneCurrently Active Slave: enp0s3MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0 Slave Interface: enp0s3MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 08:00:27:66:20:41Slave queue ID: 0 Slave Interface: enp0s8MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 08:00:27:59:5c:9aSlave queue ID: 0</syntaxhighlight>何となくですが…動作モードは「active-backup」でアクティブが「enp0s3」、「enp0s8」は待機しています。  これだけでは不安なので、「enp0s3」側のLANケーブルを抜いてみます。<br/>切り替わったことを、確認してみます。<syntaxhighlight lang="bash">cat /proc/net/bonding/bond0systemctl enable netctlEthernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup)Primary Slave: NoneCurrently Active Slave: enp0s8MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0 Slave Interface: enp0s3MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 1Permanent HW addr: 08:00:27:66:20:41Slave queue ID: 0 Slave Interface: enp0s8MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 08:00:27:59:5c:9aSlave queue ID: 0</syntaxhighlight> 切り替わってます!!
== 参考サイト ==
[https://wiki.archlinux.jp/index.php/Netctl#.E3.83.9C.E3.83.B3.E3.83.87.E3.82.A3.E3.83.B3.E3.82.B0 netctl - ArchWiki]<br/>
[https://qiita.com/tukiyo3/items/08c8b0180eae29055736 ArchLinuxでネットワーク設定 (ブリッジ、bonding)]<br/>
[https://github.com/joukewitteveen/netctl/blob/master/docs/netctl.profile.5.txt マスターのnetctl / netctl.profile.5.txt・joukewitteveen / netctl・GitHub]<br/>
[http://nosa.cocolog-nifty.com/sanonosa/2013/12/linuxnicbonding.html LinuxでのNIC冗長化(bonding)を少し深く考えてみる: sanonosa システム管理コラム集]<br/>

案内メニュー