Working with eve-ng (Active-Backup Bond Interfaces with eth0 and wlan0)

After a lack of updates, its’ time for a new blog post – this post is about linux networking particularly using active-backup bond interfaces for wired and wireless LAN interfaces, which is part of creating my updated virtual network lab environment.

Unetlab which was pretty much an alternative to GNS3 has now evolved into eve-ng which is quite a nice system. Amongst other things is it has a custom linux kernel that doesn’t block L2 Slow protocols like LACP. One of the things I specifically like about Eve besides having the facility to use html5 sessions to handle telnet/VNC consoles (as well as native tools) is that there are some SROS specific modifications that support the distributed VSR models as well as passing SMBIOS parameters etc.

I did a bare metal install pretty much following the process described in http://www.eve-ng.net/index.php/documentation/installation/bare-install but did a few more things.

I installed xcfe4 so I can have a graphical desktop with firefox so I can use eve locally, not just remoting into it.

I also did a few changes to the base install network configuration to allow the use of the copper ethernet as the primary interface but falling back to wireless.

Normally you cannot add a wireless interface into a bridge (normally eve binds eth0 into bridge pnet0 but simply adding wlan0 didn’t work)

Fortunately you can add a bond into a bridge, and the bond is less picky about who joins.

These are the items I added to /etc/network/interfaces

#Bond0 Config
auto bond0
iface bond0 inet manual
    bond-slaves eth0 wlan0
    bond-mode 1
    bond-miimon 100
  • bond-slaves are the link members of the bond (eth0 and wlan0 are my copper and wireless lan interfaces respectively)
  • bond-mode 1 is active-backup – Only one interface at a time will be operational, with the preference to the interface that is configured as bind-primary
  • bond-miimon 100 means that every 100ms the link state is checked
# Wireless interface
allow-hotplug wlan0
iface wlan0 inet manual
    wpa-ssid ReplaceThisWithYourSSID
    wpa-psk ReplaceThisWithYourPresharedKey
    bond-master bond0

I’m not sure if its mandatory but allow-hotplug wlan0 seems to help and bond-master seemed to be required.

The eth0 section was modified to the following

# The primary network interface
allow-hotplug eth0
iface eth0 inet manual
    bond-master bond0
    bond-primary eth0
  • Here allow-hotplug eth0 seems to wake the system to the fact a cable has been connected
  • bond-master bond0 as with wlan0, this appears to be needed
  • bond-primary eth0 means that when both eth0 and wlan0 are up, eth0 should be the one used.

And finally pnet0 was modified to use bond0 instead of eth0

auto pnet0
iface pnet0 inet dhcp
    bridge_ports bond0
    bridge_stp off

So after issuing a “service networking restart”, here’s our verifcation that the bond interface is up:

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

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
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: d0:67:e5:57:12:9e
Slave queue ID: 0

Slave Interface: wlan0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 24:77:03:b1:9f:78
Slave queue ID: 0
root@m4600:~# brctl show pnet0
bridge name     bridge id               STP enabled     interfaces
pnet0           8000.d067e557129e       no              bond0
root@m4600:~# ip -4 addr show pnet0
4: pnet0:  mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.1.31/24 brd 192.168.1.255 scope global pnet0
       valid_lft forever preferred_lft forever

Quick Network Verification:

root@m4600:~# ping 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=30.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=24.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=28.3 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 24.924/27.798/30.131/2.164 ms

Summarise the bond status:

root@m4600:~# grep -A 1 "Interface\|Primary" /proc/net/bonding/bond0
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: wlan0
--
Slave Interface: eth0
MII Status: down
--
Slave Interface: wlan0
MII Status: up

Now Pull out the Ethernet cable

root@m4600:~# ping 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=28.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=35.6 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=27.9 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 27.910/30.537/35.614/3.593 ms

Verify the bond interface is using wlan0

root@m4600:~# grep -A 1 "Interface\|Primary" /proc/net/bonding/bond0
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: wlan0
--
Slave Interface: eth0
MII Status: down
--
Slave Interface: wlan0
MII Status: up

Re Insert the Ethernet cable

root@m4600:~# ping 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=23.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=21.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=23.1 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 21.968/22.822/23.397/0.628 ms
root@m4600:~# grep -A 1 "Interface\|Primary" /proc/net/bonding/bond0
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0
--
Slave Interface: eth0
MII Status: up
--
Slave Interface: wlan0
MII Status: up

So this is all good. (Actually during this testing, I was SSHed into the laptop and the session didn’t break)