If your whole business depends on one internet provider, then every outage is your outage. A second connection, even a slower or more expensive one, can keep your customers online while the first is repaired. A MikroTik router can switch between the two by itself.
What failover means
You have two connections, called the primary and the backup. Normally all traffic goes through the primary. When the primary stops working, the router moves traffic to the backup. When the primary comes back, the router moves back. Customers may notice a short pause, but they do not need to do anything.
Why a plain cable check is not enough
The simplest setup gives the primary route a lower "distance" so the router prefers it. The problem is that the router only notices a failure when the cable or modem link goes down. Most real outages are different: the cable is connected and the modem is on, but your provider's internet is broken further away. The router still thinks the primary is fine and keeps sending traffic into the void.
Recursive routing: check the real internet
To fix that, the router must test the real internet through the primary connection. The usual method is recursive routing:
- The router keeps a small route to a well-known address on the internet, for example a public DNS server, through the primary gateway.
- The main default route points to that address instead of straight to the gateway.
- If the test address stops answering through the primary line, the main route becomes inactive and the backup route takes over.
Many owners use two different test addresses, so that a problem with one public server is not mistaken for an outage.
What you need before you start
- Two working internet connections, each with its own gateway address. Write both down.
- A separate port on the router for each connection.
- Masquerade (NAT) for both connections, so that customers can use either one.
- A plan for customers with fixed addresses or port forwards. Those only work through the connection they were set up on, so decide what happens to them during a failover.
A warning about changing gateways
If a provider gives its address by DHCP, the gateway address can change. A route that was set with the old gateway then stops working. Use a method that follows the DHCP gateway, or ask the provider for a fixed address.
How to test it safely
- Do it at a quiet hour and keep a way to reach the router locally, in case you lock yourself out.
- Confirm the primary is used: run a trace to a public address and see which gateway appears.
- Unplug the primary on purpose, or block it, and watch the router switch. It should take from a few seconds to about half a minute.
- Plug it back and check that traffic returns to the primary.
Things to watch afterwards
- Backup cost. A metered backup, such as a mobile data plan, can become expensive if it carries all your customers. Consider limiting speeds while it is in use.
- Both lines through one power supply or one pole. If both connections fail together, you have no real backup. Use different providers and, if possible, different routes into the building.
- An alert. Failover that nobody knows about hides the problem. Set up a notification when the router switches, so you can chase the provider.
A second provider costs money every month, but compared with a day of angry customers and refunds, many small providers find that it pays for itself quickly.