Sharing

2012年4月26日 星期四

Network Bonding on Ubuntu 11.10

NIC Bonding and IP Aliasing on Linux
http://maxubuntu.blogspot.com/2011/07/nic-bonding-and-ip-aliasing-on-linux.html

有很清楚的表格指出  NIC Bounding 每一種模式的差異及使用方式
也有很多很棒的連結


參考文章:


Tech黑手 - 工作雜記 網卡綁定 Network Bonding
http://chunchaichang.blogspot.com/2010/08/network-bonding.html

     裡面有提到如何驗証你的網路速度

實際操作

雖然看了很多資料, 但實際在設定時還是有一些問題, 首先 Ubuntu 11.10 的設定方式和之前的版本不太相同,
有些參數 bond_xxx 也變成 bond-xxxx, 所以要注意一下自己用的 ifenslave 的版本

wistor@wistor:~$ dpkg -l | grep ifen
ii  ifenslave-2.6                      1.1.0-19ubuntu1.1                         Attach and detach slave interfaces to a bonding device

/etc/network/interface 的設定如下, 要分別就 eth0 及 eth1 設成它的 bond-master
然後 bond0 的介面就不必設定 slave, 然後在這邊我使用 active-backup 模式, 也可以用數字 1 代替
至於還有那些模式, 就請看之前的 kernel.org 那篇文章

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
        bond-master bond0

auto eth1
iface eth1 inet manual
        bond-master bond0

auto bond0
iface bond0 inet static
        address 172.17.123.81
        netmask 255.255.0.0
        gateway 172.17.1.254
        bond-slaves none
        bond-mode active-backup
        bond-miimon 100
        bond-fail-over-mac 1


wistor@wistor:~$ /etc/init.d/networking restart
wistor@wistor:~$ ifconfig
# 可以看到 bond0 有 MASTER 的字樣
# 而且可以發現 bond0 的 HWaddr 和目前 active eth0 是一樣的
bond0     Link encap:Ethernet  HWaddr 00:26:2d:0a:36:a4
          inet addr:172.17.123.81  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::226:2dff:fe0a:36a4/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:12070 errors:0 dropped:5340 overruns:0 frame:0
          TX packets:1683 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1405277 (1.4 MB)  TX bytes:222703 (222.7 KB)

# 可以看到 eth0 有 SLAVE 的字樣
eth0      Link encap:Ethernet  HWaddr 00:26:2d:0a:36:a4
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:6688 errors:0 dropped:173 overruns:0 frame:0
          TX packets:1572 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:782495 (782.4 KB)  TX bytes:210253 (210.2 KB)
          Memory:fbea0000-fbec0000

eth1      Link encap:Ethernet  HWaddr 00:26:2d:0a:36:a5
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:5382 errors:0 dropped:5150 overruns:0 frame:0
          TX packets:111 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:622782 (622.7 KB)  TX bytes:12450 (12.4 KB)
          Memory:fbee0000-fbf00000

# 這個指令可以看的更清楚有那些 slave 綁在 bond0 下面, 以及目前那一個是 Active
wistor@wistor:~$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:26:2d:0a:36:a4
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:26:2d:0a:36:a5
Slave queue ID: 0


如果 bonding 和 bridge 要一起使用

wistor@wistor:~$ sudo cat /etc/network/interface
iface lo inet loopback

auto eth0
iface eth0 inet manual
        bond-master bond0

auto eth1
iface eth1 inet manual
        bond-master bond0

auto bond0
iface bond0 inet manual
        bond-slaves none
        bond-mode active-backup
        bond-miimon 100
        bond-fail-over-mac 1


auto br0
iface br0 inet static
        address 172.17.123.81
        netmask 255.255.0.0
        gateway 172.17.1.254
        bridge_ports bond0

wistor@wistor:~$ sudo brctl show
bridge name     bridge id               STP enabled     interfaces
br100           8000.02163e1b9bce       no              bond0

更多的參數設定可以看 /usr/share/doc/ifenslave-2.6/README.Debian.gz


沒有留言: