Channel Bonding to share the same IP for Bridged wired & Wireless interfaces

This is a variation of Channel Bonding to share the same IP for Wired & Wireless interfaces, it replaces the wired interface with a bridged interface. I use this to run kvm, hence I've included the configuration items to bring up a virtual network device (TAP) that can be used by virtual machines to integrate seamlessly with the actual LAN.

Currently only written for Debian systems.

FIXME: This seems to fail in bringing the bridge up automatically and hence you'll need to set it up and run the dhcp client manually after setup

Debian-style

In Debian this can be achieved directly through /etc/network/interfaces:

allow-hotplug bond0 # or "auto bond0"
iface bond0 inet dhcp
	bond-primary br0
	bond-slaves br0 wlan1
	bond-mode active-backup    # or bond-mode 1
	bond-miimon 150
        pre-up ifconfig bond0 hw ether 00:11:22:33:44:55
        pre-up ifconfig eth1 promisc
        post-down ifconfig eth1 -promisc
	pre-up brctl addbr br0        # Create bridge
	pre-up ip link set eth1 up    # Bring eth1 up
	pre-up ip link set br0 up     # Bring br0 up [NOTE: FAILS silently]
	post-up ip link set br0 address 00:11:22:33:44:55  # Set br0's MAC to ours instead of a random one. TODO: Doesn't seem to work either
	post-down ip link set br0 down  # Bring br0 down
	post-down brctl delbr br0       # Remove bridge

allow-bond0 wlan1
#allow-hotplug wlan1
iface wlan1 inet manual
        bond-master bond0
        bond-primary eth1
        bond-mode active-backup
        bond-miimon 150
        # Usually optional: set wlan1 as active temporarily, tell wpa_supplicant to use bond0
	#bond-give-a-chance 10
	#wpa-bridge bond0
        #
	# Single Wireless location/access point:
        #wpa-ssid "#MY SSID#"
	#wpa-psk #MY KEY#
        # Multiple wireless locations
        wpa-roam /etc/wpa_supplicant/wpa-roam.conf   # And set-up wpa-roam.conf with SSIDs and Keys

auto eth1
iface eth1 inet manual

allow-bond0 br0
iface br0 inet manual
	bond-primary br0
	bond-master bond0
        bridge_ports eth1 tap0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
        # Set up a TAP interface as tap0
	pre-up ip tuntap add dev tap0 mode tap user root
	pre-up ip link set tap0 up
	post-down ip link set tap0 down
	post-down ip tuntap del dev tap0 mode tap

Enable with:

# ifup bond0     # This fails to bring br0 up and hence DHCP will fail
# ifconfig br0 up
# dhclient -v br0

With cable connected, eth1 is used. Without, wlan1 is used.
See status with $ cat /proc/net/bonding/bond0:

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

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

Slave Interface: wlan1
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:11:22:33:44:55
Slave queue ID: 0

Slave Interface: br0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:aa:bb:cc:dd:ee
Slave queue ID: 0

References

linux/bonding-bridge.txt · Last modified: 2016/04/04 01:39 by Toni Corvera
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki