Given two redundant WAN on ether1 and wlan1, I’d like to have ether1 route preferred over wlan1, in case both are available.
Current setup has two DHCP clients with two separate IP addresses. I tried a lower “Default Route Distance” for ether1 in its DHCP Client > Advanced options, but IP > Routes shows two 0.0.0.0/0 routes, DAS and DS, both “reachable wlan1”. A static route to 0.0.0.0/0 over gateway ether1 does not work (not reachable), why? Temporarily disabling wlan1 changes the route to ether1 gateway as expected.
no need to enforce, once you see the correct route is black, that means it’s active, and that’s what the route for your internet uplink.
the other fail-over route, is blue, and while it is reachable, no traffic is routed towards this gateway.
to test, just type what is my ip address on google, it tells you which public IP you are currently behind.
and if setup correctly, if you unplug ether1, the route via wlan1 should turn from blue to black, meaning it is now active,
watch your dns setting so you don’t use the DNS for one route, obviously when you use another route, this DNS server won’t be available. I’d use something like 1.1.1.1
Thanks for digging in but I think there is still a misunderstanding.
I have an Ethernet cable plugged to ether1 and an active WiFi connection at wlan1 interface. Both are connected to the internetz and configured as WAN. Now I want to have the route to 0.0.0.0/0 via ether1 interface active (as it is faster), but for a reason I do not undestand, the router choses the route via wlan1 to be active. The wlan1 route shall only become active as fallback, once the ether1 is not available.
I think, with distance on ether1 set to 1 and distance on wlan1 set to 2, as long as ether1 is running, Mikrotik will route all traffic through ether1. this is what you want yes?
you will see both route showing up in routing table and both can be dynamic / static, but the lower distanced is active and is shown as Black, while the higher distanced route is reachable but not active, and is shown as Blue. https://wiki.mikrotik.com/wiki/Manual:IP/Route#Route_selection
Candidate route with the lowest distance becomes an active route. If there is more than one candidate route with the same distance, selection of active route is arbitrary (except for BGP routes).
Yes, exactly. But this is not what the router does
With distance you are referring to the default-route-distance in IP > DHCP-Client, right?
It’s true that both routes are created while only one is active but my problem is that both routes show “reachable wlan1”:
/ip dhcp-client print detail
Flags: X - disabled, I - invalid, D - dynamic
0 ;;; defconf
interface=ether1 add-default-route=yes
default-route-distance=1 use-peer-dns=yes use-peer-ntp=yes
dhcp-options=hostname,clientid status=bound address=192.168.144.170/24
gateway=192.168.144.254 dhcp-server=192.168.144.210
primary-dns=192.168.144.210 secondary-dns=8.8.4.4
expires-after=1w23h34m48s
1 interface=wlan24 add-default-route=yes default-route-distance=2
use-peer-dns=yes use-peer-ntp=yes dhcp-options=hostname,clientid
status=bound address=192.168.144.175/24 gateway=192.168.144.254
dhcp-server=192.168.144.210 primary-dns=192.168.144.210
secondary-dns=8.8.4.4 expires-after=1w23h59m9s
/ip route print detail
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
0 ADS dst-address=0.0.0.0/0 gateway=192.168.144.254
gateway-status=192.168.144.254 reachable via wlan24 distance=1
scope=30 target-scope=10 vrf-interface=ether1
1 DS dst-address=0.0.0.0/0 gateway=192.168.144.254
gateway-status=192.168.144.254 reachable via wlan24 distance=2
scope=30 target-scope=10 vrf-interface=wlan24
...
The traffic is routed via wlan2 - I can say this for sure as Interfaces show traffic on wlan2 and in my case, wlan2 speed is ~5 Mbps while ether1 is 100 Mbps. When deactivating wlan2 interface I reach again 100 Mbps.
I guess this is something to do with the fact both DHCP client share the same gateway, and DHCP server. so when the route changes, the gateway 192.168.144.254 remains the same
So they are connecting to the same router for Internet access ? I assume you want some redundancy if ether1 fails.
in this case, I am not sure what’s the best way forward as this is not a common scenario.
but first try not use add default route in DHCP client, add static route yourself and use the interface as gateway, instead of an IP address. I am not sure if this is going to make a difference but it’s easy enought to try.
few things also come to mind, OSPF with metric
or you want to try script, you can enable wlan1, only when ether1 is not running,
So they are connecting to the same router for Internet access ? I assume you want some redundancy if ether1 fails.
Exactly.
but first try not use add default route in DHCP client, add static route yourself and use the interface as gateway, instead of an IP address. I am not sure if this is going to make a difference but it’s easy enought to try.
I tried that as initially described. With the Route being active (AS), I don’t have internet - is there a way to see why not? Even with both gateways set and reachable:
/ip route print detail
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
0 A S dst-address=0.0.0.0/0 gateway=ether1,wlan1
gateway-status=ether1 reachable,wlan1 reachable distance=1
scope=30 target-scope=10
... (others are DS)
few things also come to mind, OSPF with metric
But that would require the above to work, right?
or you want to try script, you can enable wlan1, only when ether1 is not running,
Uh. I was hoping to avoid scripts for such a simple problem
static route should work , mikrotik need 3 things to get wan interface working: route, correct IP on the interface and NAT.
I will setup a lab test and see how to get it working. no pint me trying suggesting something I am not 100% sure.
in the meantime, I think a simple bounding would definitely work, so you bound the ether1 and wlan ,in “active-backup” mode. have a look . I have tested load balancing rr mode which was not complicated to setup. have a look wiki examples.
in the meantime, I think a simple bounding would definitely work
Thank you very much solar77! This is exactly what I was looking for. No custom routes, just a redundancy, perfect At first I was a bit frustrated because it did not work, but a router reboot solved it.
What I did: Added both interfaces to the bonding with “active-backup” mode. Added bonding to WAN interface list. Added DHCP client for bonding, disabled the other DHCP clients. Ensured Firewall/NAT links to WAN interface list.
glad it worked for you. I got my head stuck in trying to figure out the routing part, only realized bounding is the answer as I type up the last reply.
it would interesting to find how smooth the fail-over is and test if it causes noticeable drop in voip call or online gaming.
The duration of fail-over is not of importance for our application.
I did a quick non-formal test and the outage was approx 4.5 seconds for each of both directions (i.e. master->slave, plugging of ethernet cable, and slave->master, plugging back ethernet cable).
Thanks again!
I’m not sure what happened but my failover WAN (via wlan1) isn’t working anymore. I have a failover WAN bonding interface with active-backup and mii monitoring:
The router gets IP and Gateway via DHCP, but is unable to ping the WAN router. After some time I found that there seems to be a MAC address confusion.
What I understand from the documentation …
The MAC address of the bonding interface is presented onto the active port to avoid confusing the switch.
… is that the bonding interface should have a separate MAC address?
In my current setup, only wlan1 is connected. However, the MAC address of ether1 is presented in the bonding interface, although ether1 is not connected (no link). Only if I force the MAC address to the one from the wlan1 interface, I get WAN connectivity. Removing the forced MAC address, the interface MAC changes again to the one from ether1 and there is no WAN connectivity.
Is this expected behavior? What can I do to get around this?
Bonding intended to connect two physical interfaces to the same other equipment and bond those links together.
It is to create faster speeds over for example 1Gbps ethernet, by using two or more of them…
It is kind of “one interface” afterwards.
You can not use this on two outgoing (WAN) interfaces which have different IP etc. (bonding needs the same mechanism on the other end).
Normally you should do:
Use your DHCP client on ETH1 with “add default route” checked. and on your DHCP client on WLAN uncheck the default route.
In IP/Route add one route for 0.0.0.0 with distance “20” that goes towards your WLAN interface…
This one will not be active until you DISCONNECT the ETH1 ethernet cable, or the device your box is connected is switched off!!!
All this setup does not cover the case where your modem will be up and running but your internet connection is lost.
For this you need to have recursive routes with failover. There is a good topic on this by Chupaka…!
Use your DHCP client on ETH1 with “add default route” checked. and on your DHCP client on WLAN uncheck the default route.
In IP/Route add one route for 0.0.0.0 with distance “20” that goes towards your WLAN interface…
This one will not be active until you DISCONNECT the ETH1 ethernet cable, or the device your box is connected is switched off!!!
Thanks a lot, it works in principle, however, with two caveats:
If I just add a route via wlan1, it does not work. I had to specify the gateway IP address which is unfortunate. RouterOS says wlan1 reachable, but does not route unless I manually set the gateway.
If I connect ether1, it dynamically adds the route and works fine. If I unplug, the DCHP client remains bond (why?) and thus does not delete the dynamic route. Is there a way to have the DHCP binding released once interface has no link (without using periodic scripts)?