Experience

Easy and Affordable Home Fail-Over Solution with Ubiquit and TP-Link

490views

Has your internet ever gone down at home, forcing you to hotspot off your phone temporarily? Hopefully this isn’t happening too often, however when it does happen we found that it is really annoying to have a non-functional home network. Wouldn’t it be nice to fail-over to a spare sim-card with data you will probably never use up otherwise?

Pre-Requisites

For this setup you will need:

  • Ubiquiti Edgerouter Lite: Or something similar from Ubiquiti should also work. This is our load-balancing device.
  • TP-Link TL-MR6400: Or a similar device which lets you insert a sim card to get data.
  • 4G/3G Data Plan / Signal: You will obviously need to have a mobile broadband data plan and signal where you would like to set this up.

What you will need.

The Steps

We will keep these steps as easy as possible, as we found instructions on the internet mostly technical and difficult to follow.

  1. Plug-in and Setup the TP-Link with your data SIM Card – Connect this setup to your computer and ensure that internet can be accessed through your SIM card before proceeding.
  2. DHCP on the TP-Link – We made the mistake of turning off the DHCP on the TP-Link device. Do not turn this off, but rather change the IP address set to not conflict with your current Ubiquiti DHCP setup. For example our Ubiquiti DHCP is 192.168.1.XXX so we modified the TP-Link addresses to 192.168.2.xxx
  3. Connect TP-Link to the Edgerouter Lite – Connect the TP-Link you have just setup by plugging it via a network cable into a free Edgerouter network port. No need to turn the TP-Link on at this stage. Our setup is eth0 (WAN 1 – Primary Internet), eth1 (LAN with DHCP), eth2 (WAN 2 – TP-Link). Your setup can differ and does not have to be the same port to port. We also connected to the second LAN port on TP-Link (not the one labelled WAN/LAN) however we are relatively sure other ports should work.
  4. Edgerouter Configuration Backup – The steps below are a little more involved. Make sure you back-up your configurations for the Edgerouter in full before proceeding. As the wizard below will wipe all configuration settings, you can back-up valuable configurations by opening the CLI interface and typing the below command: “show configuration commands”. Note that this may be quite long, and will be used to restore any useful settings later on such as static mapping of IP’s, port-forwarding and firewall rules. In our case we had a lot of static IP device mapping which we restored in a speedy fashion this way.
  5. Load Balancing Wizard – Navigate to Wizard (top right corner of browser interface) and click “Load Balancing” (not Load Balancing2).
  6. Configuring Load Balancing – Below is a screenshot corresponding to what we’ve done. This is with the assumption that eth0 = WAN1, eth1 = LAN, eth2 = WAN2 as per described before. Your setup may vary. It is important to tick “Only this interface if the other fails” unless you want to configure a balanced loading. Our internet connection is also pppoe but your primary connection may be different. Please select what is applicable here. The TP-Link 4G internet is done through DHCP internally which we mentioned which will assign the Edgerouter a 192.168.2.XXX address which works fine in our case.
  7. Are You Sure? – Before proceeding, make sure you have a backup and output of the “show configuration commands” as once the changes are applied all the configurations will be overwritten! We realise there are more skilful ways to create a fail-over setup through CLI and config-tree however we found the wizard to be the most straight-forward albeit configs are overwritten.
  8. Restore Configurations – This step can be a bit fiddly. Once the Edgerouter has restarted, you will have realised that all your configurations are overwritten much like a factory reset. Selectively pick-out command outputs from the “show configuration commands” list which you would like to restore. Not all are applicable and in our instance we picked out the “set servce dhcp-server …” commands to restore our static mapping of IP addresses. Note that your shared-network-name in the output commands may no longer be incorrect, in our case our old name was LAN1 and our new name is simply LAN. This needs to be replaced accordingly before commands are executed. The commands can be copy and pasted (multiple lines too) into the CLI, however prior to executing these commands please ensure that you are in configuration mode by executing “configure”, after executing the commands you will need to execute “commit” and then “save“.
  9. Turn on TP-Link – It is recommended to restart your Edgerouter after the last step, then its time to turn on your TP-Link. Wait for both devices to properly finish booting. In the web interface you should be able to see eth0, eth1 and eth2 all connected.
  10. Ensure Load Balancing is Set – Open the CLI for Edgerouter and type in command “show load-balance watchdog” and you should see the interfaces as below:
  11. Ensure Load Balancing Weighting is Correct – Open the CLI for Edgerouter and type in command “show load-balance status” and you should see the output as below:
  12. Setting the lb-local-metric option to ensure router uses the correct active WAN – this step is extremely important otherwise if you miss this step, and your secondary connection fails whilst your primary connection is still active, DNS resolution would stop working. In the command line type in the following commands:
    configure
    set load-balance group G lb-local-metric-change enable
    commit
    save
    exit
  13. Testing Fail-Over – Now to the moment of truth, unplug the link between Ubiquiti and your primary internet (i.e., unplug the cable) and wait for a few seconds to see if the fail-over runs correctly. If successful, plug back in and wait for a few minutes for both links to be up and running again, then repeat the process for your secondary connection. If killing your secondary connection affects your primary connection, then you did not execute step 12 above properly.

Bonus Configurations

You may also want to:

  • Change the Health-Test Target: You can do this either through the commandline or through the config tree. Command is outlined in the resource below, and config tree is located at Load-Balance->Group->{NAME}->Interface->{INTERFACE_NAME}->route-test->type->ping. Simply enter the address you would like to execute on health-check. We recommend 1.1.1.1 or 8.8.8.8.
  • Find out more information: Here’s the official Ubiquiti Resource.

It is a bit of an involved process to setup a fail-over, however this has been made within reach of home consumers thanks to Ubiquiti.

If you have any questions, please shout in the comments and we will do what we can to help out. Good luck!

Leave a Response