Community discussions

 
alanbrooks
just joined
Topic Author
Posts: 6
Joined: Thu Aug 09, 2018 6:25 pm

Switching WANs by Host Gateway Selection

Sat Sep 01, 2018 5:49 pm

I have a need to switch the WAN hosts might use when connected to a Mikrotik router (RouterBOARD 3011UiAS / 6.42.6) on the fly. I used to accomplish this by having two routers (connected to different ISPs) on a LAN and just switching the gateway on the host with a script but now I would like to do this with just the Mikrotik.

Currently, I have 2 WANs set up on the Mikrotik and 2 vlans using two bridges as well. ether1 is WAN1, ether3 is WAN2, ether6-8 are vlan11 and ether9-10 are vlan10. I would like to allow hosts on vlan10 the ability to somehow pick the WAN they are using as well as keep the way they are currently operating (which is load sharing over both WANs.) So, for example, the host would execute a script I've written to change its ethernet settings from IP=192.168.1.40/24 GW=192.168.1.1/24 DNS=8.8.8.8 to IP=192.168.1.40/24 GW=192.168.1.2/24 DNS=8.8.8.8 thereby choosing WAN 2.

Can this be achieved and would it be done through routing or mangle rules or both? Any suggestions would also be greatly appreciated!
 
Sob
Forum Guru
Forum Guru
Posts: 4811
Joined: Mon Apr 20, 2009 9:11 pm

Re: Switching WANs by Host Gateway Selection

Sun Sep 02, 2018 3:10 pm

Yes, it's possible. You just need a way how to tell which gateway the host used.

It's not possible to tell directly, because hosts use IP address of gateway only to look up MAC address and send packets there. So when they arrive on router, you can't tell if used gateway was 192.168.1.1 or 192.168.1.2, because destination MAC address is the same.

But you can have 192.168.1.1/24 on interface and add 192.168.1.2/32 using VRRP. It will be visible on network as before, but with different MAC address and on router you'll be able to use in-interface=<vrrp interface> to match traffic that used 192.168.1.2 as gateway.
People who quote full posts should be spanked with ethernet cable. Some exceptions for multi-topic threads may apply.
 
alanbrooks
just joined
Topic Author
Posts: 6
Joined: Thu Aug 09, 2018 6:25 pm

Re: Switching WANs by Host Gateway Selection

Mon Sep 10, 2018 7:08 am

Thank you for your reply.

I'm a little confused about how VRRP is implemented on a Mikrotik device. I am assuming the VRRP is a virtual implementation that resides inside one physical box. But when reading the Mikrotik VRRP examples, the page states "Now unplug ether1 cable on router R1. R2 will become VRRP master, ARP table on client will not change but traffic will start to flow over R2 router..." which sounds like their example is separate physical devices since unplugging ether1 in my notion of VRRP would kill both R1 and R2.

Further on, on the same page in the Load Sharing section, the config is using the same ether1 on both R1 and R2. That seems like it has to be two physical routers since there's no way R1 and R2 could use ether1 in the same box and load share to two different WANs. Am I missing something or thinking about this completely wrong?

FYI - I have two WANs on ether1 and ether3. I also have two vlans and two bridges. Can those co-exist with VRRP?
 
Sob
Forum Guru
Forum Guru
Posts: 4811
Joined: Mon Apr 20, 2009 9:11 pm

Re: Switching WANs by Host Gateway Selection

Mon Sep 10, 2018 11:56 pm

Well, you don't specifically need VRRP. Basic idea of VRRP is to create virtual router from two or more physical routers. E.g. you want always available gateway with IP address x.x.x.1, so you take two routers, give them x.x.x.2 and x.x.x.3, configure VRRP on them and whichever is master will handle the x.x.x.1. If master dies, backup router will immediatelly take over and users won't notice.

In your case, it's just a way how to get another MAC address on same interface, link it with the other gateway IP address and be able to tell which one client used. So it would be degraded VRRP with only master router. It would be better to use some static virtual interface, but RouterOS doesn't support those.

VRRP should not have any problem with other interfaces, add it on top of interface where you have 192.168.1.1/24, assign 192.168.1.2/32 to VRRP interface and it should work. Then you can use mangle rules based on incoming interface (VRRP or parent).
People who quote full posts should be spanked with ethernet cable. Some exceptions for multi-topic threads may apply.
 
alanbrooks
just joined
Topic Author
Posts: 6
Joined: Thu Aug 09, 2018 6:25 pm

Re: Switching WANs by Host Gateway Selection

Wed Sep 12, 2018 5:04 pm

Thank you for your replies. My problem was that I was thinking of the virtual router as being on the same "level" as the bridge in my router so I was attaching the VRRP to the WAN interface. After your last post, I realized that it should be attached to the bridge.

Who is online

Users browsing this forum: No registered users and 25 guests