Best way to configure Bonding in OpenWrt?

Is there a UCI standard way to configure bonding? I didn't see one when skimming the /etc/config/network wiki page.

If not, what's the best way to configure bonding? Suppose I want to bond eth0 and eth1 into bond0 and then set up VLANs on bond0 such as bond0.1 and bond0.2?

Is the best way to do this with the "ip" (ip-full) command in /etc/rc.local and then restart networking afterwards so the UCI can pick up the bond0 device and create the VLAN virtual devices etc?

1 Like

Something like this in /etc/rc.local using ip full?

ip link add type bond name bond0
cat "balance-rr" > /sys/class/net/bond0/bonding/mode

ip link set eth0 master bond0
ip link set eth1 master bond0

# until we set up the bond your uci config will reference
# nonexistant bond0 device so now we have it, we'll restart here.

/etc/init.d/network restart 

If the UCI config lists say bond0.1 and bond0.2 as the LAN and WAN devices will this work, and get set up by UCI fine after restarting network?

1 Like

With kmod-bonding and mii-tool installed, add this to your /etc/rc.local (modify it for your needs):

modprobe bonding mode=balance-rr miimon=100
ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up
ip link set eth0 master bond0
ip link set eth1 master bond0

Add this to /etc/config/network:


config interface 'bond0'
	option ifname 'bond0.1 bond0.2'

Set the bond VLAN's on the WAN and LAN interfaces accordingly in /etc/config/network. Example:


config interface 'lan'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ifname 'bond0.1'

config interface 'wan'
	option proto 'dhcp'
	option ifname 'bond0.2'

Not sure if it's the best way, but it should work.

Seems like everyone has been stuck with 1Gig interfaces for over a decade... It's about time for one of the consumer level router/switch manufacturers to make a reasonably priced 10Gig router/switch.

The prices are coming down, but very slowly. Netgear has some nice 10Gig options, but it's still going to cost quite a bit.

My point is we have folks relegated to bonding 1Gig ports, and perhaps that's all that's needed for some, but it would be nice to have more hardware enabled products for the masses.

Going to need an x86 to handle a 10gig nic anyway, so if you do want a 10 gig router you can build it with an x86 and a 10gig pcie card. Bonding in my case is also for helping someone set up a dual nic on an x86

1 Like

Hopefully it's not to far down the road. Apple is shipping current Mac Minis with 10GigE, so there should be some drive to the consumer market for that.


I can hear it now though, "How can I get my <insert decade old, 8/32, 400 MHz MIPS router here> to use 10GigE? I can't get the kernel modules to fit..." followed quickly by "its working but I only get 87 mbps."

6 Likes

Can I use the same method to bond two GRE tunnels and run DHCP over it ?

Thanx in advance for your answers and time,
regards,
mmn

Umm not really sure how that would work, test it and let me know :grin:

Maybe someone can help me out, I'm not sure if this would work for me. I have two WAN interfaces named 'wan' and 'wan2'. One is through the standard ethernet port on my router for WAN connections, the other is a USB connection via easytether. WAN is the USB connection, metric of 10, WAN2 is ethernet, metric of 20. I would love to bond these two connections together so when WAN2 gets throttled, I can still add its bandwidth to WAN. I don't have broadband out where I am per se, WAN2 is connected to a 4G router with a 15gb per month max, after which it gets throttled to 600kpbs, which as we know isn't good for much of anything. However WAN (cell phone) via easytether doesn't track tether usage, so it just counts as cell internet which, while 'reprioritized' after 22gb per month, doesn't slow down nearly as dramatically. Also, network engineering is definitely not my strong suite so I prefer to ask before I just up and try something so as to avoid 10 hours of banging my head on a wall wondering why it won't work. Thanks!

Bonding requires the other end to combine the two links back into one interface. So you can't do it with two separate ISPs.

The situation you have would instead be load balancing, which you can do with the mwan3 package. It works best if the two ISPs are about the same speed though.

Ah, okay. Yeah, I'm looking for something more like running both connections at the same time and combining their bandwidth. I would've thought there'd be a way to do that. Thanks for the answer!

Mwan3 will split connections across two ISPs so that you can have more concurrent connections, and hence more total bandwidth, but it won't make any single connection faster.

there are. but it is kinda complicated and you need a server.
example: https://www.openmptcprouter.com/

@dlakelan Did you get it to work?
If i understand correctly, bonding will combine two nic's (1G+1G=2G) to have more bandwidth, but it should be set on both routers?!, bond 2 nic's on the first router and do the same on the second router?

Is it possible to combine two PPPOE connections via Mwan3 to faster internet?, cause it's possible to have more than one username and password.

One more question, is it possible to access my router remotely while ISP doesn't provide public ip, i think
vpn is the only way right now!

It works fine but as far as I know there is no UCI config etc, it's all manual.

Bonding isn't just about more bandwidth, it also offers ductility to failure, if a cable is faulty etc. And more parallelized CPU usage, handling multiple NICs.

Yes it requires the "other end" to support it. In this case just a smart switch with a link aggregation group.

If you set up mwan3 it can split your connections across multiple ISPs, no single connection will be faster but you can have more of them without saturation.

2 Likes

Thanks for the info, it's not a big problem if there's no UCI to set it up, but a script that will run at startup will do the job.
i mean two pppoe connection on the same isp!

It seems doable, but a second ISP would also provide ductility, if one has an outage the other takes over, etc.

Isp's here never goes off, cause they have more than one upstream provider.
but i know some people here a buying two subscription or more then they combine them into one(to get more
download speed) using mikrotek routers, so i think the same can achievable using Mwan3.

You'll never get more than your single-line speed on a single download as it is dependent on the upstream routing which is out of your control.

However, if you split your concurrent requests across two lines, your total download speed can be up to 2x higher. In practice I'd guess it to be more "sometimes up to 1.5x or so", as it's very difficult nearly impossible for any piece of routing software to know how much bandwidth a given connection will consume prior to routing the first packet and/as you can't change the IP of the connection mid-stream, without breaking the connection.

2 Likes

Yes absolutely the same can be done with mwan3.

It's also possible to dedicate one connection for low latency communications and another for bulk communications if latency is that important (like you have a home office or something and need to make several phone calls at once and have them all be rock solid)

1 Like