
Increase Internet speed by load-balancing two WAN connections with WR740N and OpenWRT

Beware This post is more than 3 years old, it may be outdated or incorrect! Please check elsewhere for accurate information!
Update for 2020: You can now actually bond two WAN connections, to achieve aggregate speed even on a single TCP connection! Read more here ➡ OpenMPTCProuter: True Bonding of 2 WAN connections for cheap! 🎉
If you have two slower Internet connections, for example DSL and WISP, and want to join them together, this tutorial is for you! Using a cheap router, OpenWRT and some skills and time, you can convert your ordinary router into a load balancing and auto-failover routing machine! Pretty cool!
We will be using the software called mwan3
as well as iptables
to load balance the two connections.
Note: I’m using OpenWRT and LEDE project interchangeably here, because they’re the same project basically, and are merging currently, but I am using version 17.01.4, which is called LEDE and not OpenWRT.
Prerequisites
- TP-Link WR740N
- Linux machine (can be a VM)
- Two WAN internet connections
In my case, I have a DSL connection that’s about 20 Mbps down and 2 Mbps up (realistically 18/1.8 Mbps because I have IPTV and also because of DSL overhead), and a Wireless connection which is 10 Mbps down and 2 Mbps up.
The final result, is 30/4 Mbps connection, which is a perfect increase of speed and is exactly what I expected. See for yourself:
We will be using the WAN (blue) port as the “output”, or LAN, and LAN 1 and LAN 2 as the “input”, or WAN. LAN 3 and LAN 4 will be disabled.
The router’s IP will be 192.168.20.1.
Step 1: Prepare your modems
You need to go into the settings of both of your modems/routers (in my case it’s a ZTE ZXHN H267N
, and Ubiquity LiteBeam M5
for the WISP connection) and change their IP addresses so that the faster modem has the IP 192.168.1.1
and the slower one has the IP 192.168.2.1
. If they’re the same speed, pick one and give it the 192.168.1.1
IP and the other one gets the 192.168.2.1
IP.
Reboot them, make sure DHCP is turned on, and connect to each one using a network cable and verify that the IP they give your computer is in the right subnet (192.168.1.XXX
for first, 192.168.2.XXX
for second).
Step 2: Build your own OpenWRT image
Because the router we will be using is very cheap and of poor specifications, it only has 4 MB of Flash memory. This is barely enough for OpenWRT with LuCI (the WebUI) and doesn’t leave enough space for us to install other software.
On a freshly installed Ubuntu 17.10 amd64, you need to perform these steps to build the image. Please note, you will need to wait quite a while for it to download and compile and then build the final binary update.
Please do not skip this step and use a prebuilt image, as it will not work!
- Install dependencies for building the image
sudo apt -y install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev
- Download the ImageBuilder archive
cd ~
mkdir openwrt && cd openwrt
wget https://downloads.openwrt.org/releases/17.01.4/targets/ar71xx/generic/lede-imagebuilder-17.01.4-ar71xx-generic.Linux-x86_64.tar.xz
tar -xaf lede-imagebuilder-17.01.4-ar71xx-generic.Linux-x86_64.tar.xz
cd lede-imagebuilder-17.01.4-ar71xx-generic.Linux-x86_64
- Build the image for
tl-wr740n-v5
(note: replace v5 with the version of your router, i.e. TL-WR740N v4.27 should betl-wr740n-v4
)
make image PROFILE=tl-wr740n-v5 PACKAGES="-ppp -ppp-mod-pppoe -libiwinfo-lua -liblua -libubus-lua -libuci-lua -lua -luci -luci-app-firewall -luci-base -luci-lib-ip -luci-lib-nixio -luci-mod-admin-full -luci-proto-ipv6 -luci-proto-ppp -luci-theme-bootstrap -uhttpd -uhttpd-mod-ubus"
- Image has been built. The .bin firmware file we need is located in
bin/ar71xx/
, and the filename is, presumably,lede-17.01.4-ar71xx-generic-tl-wr740n-v5-squashfs-factory.bin
.
Step 3: Flash OpenWRT to your router
I am not going to dwell on this step for too much, as it’s incredibly easy to do. Place the lede-17.01.4-ar71xx-generic-tl-wr740n-v5-squashfs-factory.bin
image in a folder, reset the WR740N router to factory settings by holding the Reset/WPS button for a few seconds until all lights blink, connect to it via a network cable in port LAN1, open http://192.168.0.1/
, enter credentials admin/admin and go to System Tools on the left, then Firmware Upgrade, click the Select File button, select the firmware, making sure it has factory
in the name, and click Upgrade.
After the upgrade, reset it to factory settings again, then reboot it (turn it off, wait a few seconds, then turn it on). The lights you see should be Power, System (cog) and LAN 1. If you have anything other than LAN 1 plugged in, unplug it now.
Step 4: Configure OpenWRT
- Plug in the cable to the second router (with IP
192.168.2.1
) into the WAN (blue) port and wait until you get Internet access. - Using any terminal client (on Windows you can use PuTTY or KiTTY, which is a fork of PuTTY), connect as user
root
with no password to192.168.1.1
. You should see the LEDE banner and a shell saying[email protected]:~#
. - Run the following commands in order:
opkg update
opkg install nano
opkg install mwan3
reboot
- Wait for the router to reboot. The reason we reboot it is because
opkg
uses RAM to store the packages, and since we’re not going to be using it anymore, there’s no need to store the packages data in RAM anymore, given that we have very little. - When it’s back, run this
cd /etc/config
- Download this file and open it in some kind of text editor on your computer
- Delete
mwan3
withrm /etc/config/mwan3
- Open
mwan3
for editing withnano /etc/config/mwan3
- On your computer, copy the whole file you downloaded and then paste it into
nano
on the router. - Save the file and exit (by pressing Control+X, then Y then Enter)
- Download this file and open it in a text editor
- Delete
network
withrm /etc/config/network
- Open
network
for editing withnano /etc/config/network
- Copy the contents of the file and paste them into
nano
- Save the file and exit
- Download this file and open it in a text editor
- Delete
firewall
withrm /etc/config/firewall
- Open
firewall
for editing withnano /etc/config/firewall
- Copy the contents of the file into
nano
- Save and exit
- Reboot the router with
reboot
Check the results
Using this handy page I created, that just outputs your IP address, https://projects.milankragujevic.com/ip.php, you can see that with every refresh your IP will change, meaning that the connection is being balanced between two interfaces, wan
and wan2
.
Note: For ease of administration, I’d recommend you put another router after the WR740N if you are not comfortable administering your home network over the console interface, since the router can’t run mwan3
and also the LuCI web interface.
That’s all, thanks for reading this tutorial, I hope you have managed to double your Internet connection :)
If you want to learn more about why and how this works, and how to tweak the configuration, you can check out the links below:
- http://lartc.org/howto/lartc.rpdb.multiple-links.html (now offline)
- https://www.comparitech.com/net-admin/lartc-guide-plus-five-alternative-methods/ (thanks to K. Simmonds)
- https://wiki.openwrt.org/doc/howto/mwan3
- https://wiki.openwrt.org/doc/uci/network/switch
- https://wiki.openwrt.org/toh/tp-link/tl-wr740n
P.S. The OpenWRT/LEDE mapping of switch ports on the WR740N is wrong, and the map they provide as a fix is wrong too. The correct map is shown below:
Port 4 on router maps to Port 1 in LEDE
Port 3 on router maps to Port 4 in LEDE
Port 2 on router maps to Port 3 in LEDE
Port 1 on router maps to Port 2 in LEDE
Comments (17)

I want to use this to combine my 100mbps & 200mbps line, but i am not sure which router should i opt for.
Any suggestions? (I dont need wifi as i already have RAX40, wifi6 router). I will attach my router to this router in dhcp.
I am a long time reader and user of your blog, love it.

Hi,
just wanted to let you know the post I mentioned has been published.
Regards,
Milan

Hello,
for such speeds, I would recommend you buy either a x86 mini PC and use USB 3.0 ethernet adapters (or buy a router-specific model which has multiple ethernet ports OR a smart switch with VLAN tagging and connect the WANs to it) OR the Ubiquiti EdgeRouter X, which is well supported by OpenWrt and doesn't have needless accessories such as WiFi.
Also, very soon I will publish a truly revolutionary guide in actually Bonding two WAN connections into a single one, with aggregate bandwidth available per single TCP connection, with almost no increased latency and perfect bandwidth distribution.
It requires an endpoint server in the cloud that will serve to split the traffic to both WAN interfaces which is then recombined on the router, so check up on the blog in a few days (or maybe today) to read it.
In that case, it is a must to have either an x86 PC or a Raspberry Pi 4B, as the software isn't compatible with MIPS or ARM routers.
Thank you for staying with the blog :)
Regards,
Milan

where I can find the file to be downloaded?

Hi, all files are linked in the post, click the "this file" link and it will show you the contents. Regards, Milan

Thanks your turial! I will follow this guide. Could you help me i will post config.

not working as link aggregation only fail over

Hi, you obviously did not set it up properly, please send me your configuration files and I may be able to help you, but first try re-reading your configs and compare them to mine, because load balancing works with my configuration. Also, please be aware, you cannot bond connections with mwan3, only load balance them.

Hi there,
Can we use the WAN port + 4 LAN ports to load balance and use the wireless as LAN? My ISP provides pppoe based authentication. So, i wanted to load-balance my connection over 5 different pppoe accounts.(The internet comes in through a single cat5e cable, to a 8 port switch and then the router). Is this possible via OpenWRT or should i go for dedicated load balance routers or maybe the edgerouter x?

Hi, unfortunately I am unable to help you with a config file and a plug'n'play approach (as I don't have such a setup with which I can test), but I believe it should be possible.
How I'd do it is to setup a network config that has 5 VLANs, then for each VLAN create a wanX interface (X being number from 1 to 5) and then set them all up in mwan3, and just set up LAN with wlan0, ignorning the LAN ports completely.
I can point you to PPPoE configuration of OpenWRT here: https://openwrt.org/docs/gu...
It should be possible, but be careful if you require a certain speed, as the classic TP-Links can't process more than 100 Mbps of traffic, and are limited in their CPU power and RAM.
I have to buy a dedicated load balance multi-wan router to be able to combine 3 150 Mbps connections into 450 Mbps connection.
If you need more help, you can contact me on the email listed on my home page.
Best,
Milan

Dear Milan,
Thank you for the Tutorial. I followed the steps to convert my TpLink 740N v6. Only change I made was not to install nano but use vi to save files as I was getting memory full error. But after making all the changes my router seemed to be bricked. I am unable to connect via putty.
Can you suggest what might have gone wrong.
regards,
Ashima

Hi, You should have changed the build profile to V6, as the CPU in the V6 and V5 is different, and the image format for V6 is very different from V5. Please follow my instructions to unbrick the router (here: https://milankragujevic.com... ), but please download the V6 firmware instead of V5 or V4. Let me know if it works.

Hi Milan,
Thanks for replying. Actually the modem gets bricked when I copy the config files and reboot. Before that it works fine. So I guess firmware is OK. Can you help me with configuration files for version 6.

I might have forgot to mention, but you need to plug in the computer into the WAN port, and the WAN connections in the LAN ports. Also, you can mail me /etc/config/network default file from v6 and I'll send you a modified version that will work, as I cannot guarantee that the v5 file will work on v6, due to possible changes in the internal switch mappings. My email is milankragujevic [at] gmail [dot] com.

Thank you Milan, It worked..... So my LAN ports 2 n 3 are the new WANs. My old WAN port is LAN now. I haven't tried the old LAN ports 1 n 4. Can I make them WAN too.

It's supposed to be 1 and 2 as WAN and WAN as LAN, but it might work differently on your device. To make them all WAN, just add wan sections for eth0.3 and eth0.4 in network config and also add sections in mwan config for those wan's.

Thanks Milan,
I had managed to unbrick the router using my ubuntu box. Can you help me with the link to download the V6 firmware. This is my first handon openwrt.