Tuesday, February 10, 2015

Ubuntu Server 14.04 Network Bonding ( a simple expedient )

Ubuntu Server 14.04 Network Bonding ( a simple expedient )

Simple Ubuntu 14.04 Bonding

Just do it as below if you want to create or delete network bonding

<1> ifdown -a –exclude=lo
<2> edit network interfaces file (/etc/network/interfaces)
<3> service networking restart
<4> Done

< Using >
1. bond-mode ‘IEEE 802.3ad’
2. ifenslave (version 2.4ubnutu1)
3. service networking (13.10)

Create bonding

1) Install ifenslave

:> sudo apt-get install ifenslave

2) Restore 13.10 networking (instead of networking 14.04)

:> git clone https://github.com/metral/restore_networking.git
:> cd restore_networking/
:> ./restore_networking.sh

3) Bring network interfaces down

:> ifdown -a --exclude=lo

4) Edit /etc/network/interfaces file

:> emacs /etc/network/interfaces

auto lo eth0 eth1 eth2
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet manual # bond-slave
        bond-master bond0
iface eth2 inet manual # bond-slave
        bond-master bond0

auto bond0
iface bond0 inet static
        address 192.168.1.105
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers  8.8.8.8
        bond-mode 802.3ad
        bond-slaves none # There is no need to declare bond-slaves
        bond-xmit_hash_policy layer3+4
        bond-miimon 100
        bond-updelay 200
        bond-downdelay 200
        bond-lacp-rate 1

5) Restart service networking

:> service networking restart 

Check bonding

:> cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer3+4 (1)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200

802.3ad info
LACP rate: fast
Min links: 0
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
    Aggregator ID: 1
    Number of ports: 1
    Actor Key: 17
    Partner Key: 1
    Partner Mac Address: 00:00:00:00:00:00

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 18:bx:cc:xx:xx:xx
Aggregator ID: 1
Slave queue ID: 0

Slave Interface: eth2 # isn't used and connected with LAN (even if it ware so, no matter)
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 18:bd:23:xx:xx:xx
Aggregator ID: 2
Slave queue ID: 0

Delete bonding

1) Remove bonding (module from kernel)

:> rmmod bonding

2) Bring network interfaces down

:> ifdown -a --exclude=lo

3) Edit /etc/network/interfaces file

:> emacs /etc/network/interfaces 

auto lo eth0 eth1 eth2
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet static
        address 192.168.1.105
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers 8.8.8.8
iface eth2 inet manual

4) Restart service networking

:> service networking restart

Troubleshooting

After you set or unset ‘bonding’ , if ethernet not work.

  1. Check ‘/run/network/ifstate’ file
  2. Try to do “ifdown -a –exclude=lo && ifup -a –exclude=lo”
  3. Check LAN connector & port
  4. Check “route”

1) Check /run/network/ifstate

# ifup, ifdown commands work depending on /run/network/ifstate file
# and /etc/network/interfaces file.
# So if there are network interfaces which aren't written in /run/network/ifstate 
# file, the commands cannot perfectly work. 
# /run/network/ifstate file should have all network interfaces like this 

eth0=eth0
eth1=eth1
eth2=eth2
lo=lo

2) Try to bring down & up network interfaces

:> ifdown -a --exclude=lo && ifup -a --exclude=lo 

3) Check LAN connector & port

Check or change your LAN connector and port.
# There are sufficient cases of poor LAN connetor or port.

4) Check route

:> route

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 bond0
192.168.1.0     *               255.255.255.0   U     0      0        0 bond0

# As above this shuould be printed (if you only use bond interface)
# But output of command 'route' might not be like this.
#
# 1. Even a few minutes later, if it wasn't printed
#    check your hub or switch and try to replace port.
#
# 2. Even though bond0 has correct gateway like 192.168.1.1 
#    if your ethernet is unstable, 
#    check whether there's network interface which has IP address 
#    that use same extended network prefix.

1 comment: