Page 1 of 1

failover two wan + routing policy

Posted: Thu Jul 21, 2016 1:06 pm
by pelli
Hello, i need to implement failover for two wan with routing policy.

The scenario is:

lan: 192.168.10.0/24
wan1: 192.168.1.0/24  gw 192.168.1.254
wan2: 172.16.10.2/24  gw 172.16.10.1

i need that all connection go to wan1 except  connection to site  google.com to go to wan2

if the wan1 down all traffic go to wan2 and after wan1 is ok return to original situation.

I woul use this script for failover http://wiki.mikrotik.com/wiki/Failover_Scripting

any suggestion for policy routing and failover implementation?

Thanks

Re: failover two wan + routing policy

Posted: Thu Aug 04, 2016 11:23 am
by pelli
any suggestion? thanks

Re: failover two wan + routing policy

Posted: Tue Sep 06, 2016 10:02 am
by pelli
any suggestion? thanks

Re: failover two wan + routing policy

Posted: Tue Sep 06, 2016 2:56 pm
by Deantwo
I woul use this script for failover http://wiki.mikrotik.com/wiki/Failover_Scripting
Is there any reason you aren't just using that then?

Even more so the corrected version I already gave you.
See: http://forum.mikrotik.com/viewtopic.php ... 91#p544520
i need that all connection go to wan1 except  connection to site  google.com to go to wan2

if the wan1 down all traffic go to wan2 and after wan1 is ok return to original situation.
Ooh, well, that isn't really a scripting issue then.

Try adding this:
/ip firewall address-list
add address=google.com list=google.com
/ip route
add distance=1 gateway=172.16.10.1%Wan2 routing-mark=Google
add distance=2 gateway=192.168.1.254%Wan1 routing-mark=Google
/ip firewall mangle
add action=mark-routing chain=prerouting dst-address-list=google.com new-routing-mark=Google passthrough=no
That should make all traffic going to the google.com IP address go out of Wan2. If Wan2 is disable or its gateway unreachable, it should send it out of Wan1.
I guess you can modify the failover script to change the distance of the two google routes too if you want.

Re: failover two wan + routing policy

Posted: Fri Sep 09, 2016 6:43 pm
by pelli
I woul use this script for failover http://wiki.mikrotik.com/wiki/Failover_Scripting
Is there any reason you aren't just using that then?

Even more so the corrected version I already gave you.
See: http://forum.mikrotik.com/viewtopic.php ... 91#p544520
i need that all connection go to wan1 except  connection to site  google.com to go to wan2

if the wan1 down all traffic go to wan2 and after wan1 is ok return to original situation.
Ooh, well, that isn't really a scripting issue then.

Try adding this:
/ip firewall address-list
add address=google.com list=google.com
/ip route
add distance=1 gateway=172.16.10.1%Wan2 routing-mark=Google
add distance=2 gateway=192.168.1.254%Wan1 routing-mark=Google
/ip firewall mangle
add action=mark-routing chain=prerouting dst-address-list=google.com new-routing-mark=Google passthrough=no
That should make all traffic going to the google.com IP address go out of Wan2. If Wan2 is disable or its gateway unreachable, it should send it out of Wan1.
I guess you can modify the failover script to change the distance of the two google routes too if you want.
ok, is clear...thanks you for support!