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

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.


  1. TP-Link WR740N
  2. Linux machine (can be a VM)
  3. 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

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 and the slower one has the IP If they’re the same speed, pick one and give it the IP and the other one gets the 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!

  1. 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
  2. Download the ImageBuilder archive
    cd ~
    mkdir openwrt && cd openwrt
    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
  3. Build the image for tl-wr740n-v5 (note: replace v5 with the version of your router, i.e. TL-WR740N v4.27 should be tl-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"
  4. 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, 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

  1. Plug in the cable to the second router (with IP into the WAN (blue) port and wait until you get Internet access.
  2. 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 to You should see the LEDE banner and a shell saying root@LEDE:~#.
  3. Run the following commands in order:
    1. opkg update
    2. opkg install nano
    3. opkg install mwan3
    4. reboot
  4. 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.
  5. When it’s back, run this  cd /etc/config
  6. Download this file and open it in some kind of text editor on your computer
  7. Delete mwan3 with rm /etc/config/mwan3
  8. Open mwan3 for editing with nano /etc/config/mwan3
  9. On your computer, copy the whole file you downloaded and then paste it into nano on the router.
  10. Save the file and exit (by pressing Control+X, then Y then Enter)
  11. Download this file and open it in a text editor
  12. Delete network with rm /etc/config/network
  13. Open network for editing with nano /etc/config/network
  14. Copy the contents of the file and paste them into nano
  15. Save the file and exit
  16. Download this file and open it in a text editor
  17. Delete firewall with rm /etc/config/firewall
  18. Open firewall for editing with nano /etc/config/firewall
  19. Copy the contents of the file into nano
  20. Save and exit
  21. Reboot the router with reboot

Check the results

Using this handy page I created, that just outputs your IP address,, 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:

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

How to install MySQL on macOS

The easiest way to install MySQL on macOS Sierra or newer is to use Homebrew. Homebrew is a package manager for Mac that contains many open source projects packaged in its repositories and they can be installed with a simple command.

Step 1: Install Homebrew

If you don’t have Homebrew already (check by running brew --version, which should return something like Homebrew 1.5.4), you can easily install it by running a single command.

/usr/bin/ruby -e "$(curl -fsSL"

It’s going to ask you for your password, and it’s going to download all the necessary dependencies and then install Homebrew.

Be aware that the install will take a few minutes, depending on your Internet speed and whether you have an SSD or not, so please set aside the time to complete the install without interrupting it, as an unexpected interruption can damage the OS on your Mac.

To verify it’s been installed, run the command brew --version and verify that it outputs, without any errors, the version of Homebrew.

Step 2: Install MySQL

Run brew install mysql and enter your account password when the software prompts you.

Again, the installation will take a few minutes (usually a minute on an SSD-powered Mac with 80 Mbps Internet).

Step 3: Set MySQL to run at boot

To make sure that MySQL will start on boot, you can add it to the system’s Services list, using another command.

brew service start mysql

It should output something like this:

Successfully started 'mysql'

Step 3: Secure MySQL installation

After the installation is complete, you will have to run another command, to secure the MySQL server with a password:


It will ask you whether to enable a “VALIDATE PASSWORD PLUGIN”, answer No.

Enter your new password, and then enter it again to confirm it.

Answer Yes to everything else.

Congrats! You have installed MySQL. If you need to restart it, you can run brew services restart mysql .

If you want to administer the database using a GUI, I recommend you use the free, but excellent, app Sequel Pro.