Maybe chewing bit too much

I’m not sure if it possible what I’m trying to get done with my routerboard 450g. I try to explain it as well as I can and maybe some of you get what I’m trying to do and hopefully you guys can help me.

So I have two (2) internet connections via different ISPs. Other one is cable with one dynamic IP provided via DHCP. The other one is ADSL which have static IPv6 and IPv4 blocks.

List of IP addresses assigned to devices and interfaces:

routerboard wan1: 123.123.123.121/30 default gateway 123.123.123.122
routerboard wan1: 2001:dead:beef:a:b:c::2 default gateway 2001:dead:beef:a:b:c::1
routerboard wan2: given by dhcp
routerboard lan: 100.100.100.102/29
routerboard lan: 192.168.0.1/24
routerboard lan: 2001:beef:dead:a::1/64

server eth0: 100.100.100.97/29 default gateway 100.100.100.102
server eth0: 2001:beef:dead:a::2/64 default gateway 2001:beef:dead:a::1
server eth0: 192.168.0.2

desktop eth0: 192.168.0.10/24 default gateway 192.168.0.1
desktop eth0: 2001:beef:dead:a::3/64 default gateway 2001:beef:dead:a::1

I’d like to server use always ISP1 as it has static IP addresses.
I’d like to desktop primarily use ISP2 as NATed and if ISP2 goes down then ISP1. And as I currently doesn’t have IPv6 from ISP2 the IPv6 communication has to be always done via ISP1.

I’d imagine that this would require multiple routing tables and routing marking but I think that I’m having some sort of brain lock with this now.

Any suggestions and improvements to my network are appreciated.

So it looks quite simple, if you are familiar with policy routing a bit :slight_smile:. I assume, that you have already created the static default route on the wan1 gateway’s IP, and that it has greater distance (default=1) than the one from DHCP (default=0). Basically, now everything should go through wan2 (the default route created by DHCP client), and if it fails - then through wan1 (greater distance). The only difference you need to have is the server going always through wan1. So you need to create /ip firewall mangle rule, which does mark-routing action for every packet from the server (source IP) :slight_smile:. And create default IP route with gateway from wan1 and routing-mark the same as the label configured in mangle. And that’s it! Hope you are able to make actual commands from the tips :wink:.
If you would like to understand that better, I recommend taking a MTCRE course, there are some similar scenarios.

Sorry for delayed response.

I haven’t had time to implement this yet, but one thing that makes me wonder about suggested configuration is how to handel case when Cable connection is not working but link is up. My ISP appears to give IP address with one hour lease. Lets say that connection has been up for days and lease got just renewed when for some reason Cable connection stops working. Ethernet link to Cable modem stays up and all is ok with link according to router board. It would take lease to end before router board would give up IP address and with it default gateway for that connection.

As far as I know you can’t add gateway check for dynamically generated default gateway

That was pretty easy for the most part.

Did a small change to setup. I put 100.100.100.96/29 to own LAN and 192.168.0.0/24 different one. So now I have LAN1(100.100.100.96/29) and LAN2(192.168.0.0/24).

Only thing is that now devices from 192.168.0.0/24 network can’t connect to 100.100.100.97. Any ideas how to fix this?

@darthjysky

As far as I know you can’t add gateway check for dynamically generated default gateway

Create a route, and point it at the interface. i.e. Eth2 [I’m not paying attention to your example up there.]

Have the DHCP client not add the default route.

Now you can do checks on that “static” route that points to an interface - that does DHCP client.

If that’s not clear, do some searches and you’ll find it - it’s possible. I use it in a fail-over script I’ve written and posted here in the forums.

-Greg