Community discussions

MikroTik App
 
AnupamPradhan
newbie
Topic Author
Posts: 35
Joined: Wed May 04, 2016 2:44 pm

Static route not working

Mon Dec 03, 2018 2:57 pm

Hi,

I am using the below method for WAN failover.

I am putting host check IP(208.67.222.222) in route table to check it through ISP1 gateway only but when ISP1 is down that time also the host check IP(208.67.222.222) is able to ping from ISP2 gateway. Because of this, the netwatch script is not working properly.

Please help me to resolve this issue.

/ip route
add dst-address=208.67.222.222/32 gateway=gateway1ip
/ip route
add gateway=gateway1ip distance=1 comment=WAN1
add gateway=gateway2ip distance=2 comment=WAN2


/tool netwatch
add down-script="/ip route set [find where comment=\"WAN1\"] distance=3;\r\
    \n:log warning \"WAN1 down, switching to WAN2\"" host=208.67.222.222 up-script="/ip\
    \_route set [find where comment=\"WAN1\"] distance=1;\r\
    \n:log warning \"WAN1 restored\""

/ip route
add dst-address=208.67.222.222/32 gateway=gateway1ip
 
User avatar
Anumrak
Forum Guru
Forum Guru
Posts: 1174
Joined: Fri Jul 28, 2017 2:53 pm

Re: Static route not working

Mon Dec 03, 2018 3:05 pm

That happens because of default route of gateway2ip I suppose. In order to force ping your host through gateway1ip, assign an interface option from which you ping.

For example, ping 8.8.8.8 interface=gateway1ip
 
AnupamPradhan
newbie
Topic Author
Posts: 35
Joined: Wed May 04, 2016 2:44 pm

Re: Static route not working

Mon Dec 03, 2018 3:19 pm

Hi,

Can you please specify how. It will be really helpful.
 
User avatar
Anumrak
Forum Guru
Forum Guru
Posts: 1174
Joined: Fri Jul 28, 2017 2:53 pm

Re: Static route not working

Mon Dec 03, 2018 3:57 pm

Hi,

Can you please specify how. It will be really helpful.
via your script. Netwatch can't select an interface.
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1782
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: Static route not working

Mon Dec 03, 2018 4:07 pm

Hi

To my knowledge, you can't force a route from netwatch directly, but...

You can force route through route package:
# to add a new table for wan1
add comment=Wan1 distance=20 gateway=<wan1 gw> routing-mark=wan1
add distance=100 routing-mark=wan1 type=blackhole

# to route for that ip using that table
add action=lookup-only-in-table dst-address=208.67.222.222/32 table=wan1
 
AnupamPradhan
newbie
Topic Author
Posts: 35
Joined: Wed May 04, 2016 2:44 pm

Re: Static route not working

Mon Dec 03, 2018 6:52 pm

I think my problem was not clearly mentioned.
Forget about netwatch.

My simple issue is I have 2 WAN connection. I want to ping a particular host x.x.x.x through wan1. I used the below option in my router. But I am able to ping x.x.x.x even my wan1 link is down.

/ip route
add dst-address=208.67.222.222/32 gateway=gateway wan1
 
Redmor
Member Candidate
Member Candidate
Posts: 256
Joined: Wed May 31, 2017 7:40 pm
Location: Italy

Re: Static route not working

Mon Dec 03, 2018 9:19 pm

I think my problem was not clearly mentioned.
Forget about netwatch.

My simple issue is I have 2 WAN connection. I want to ping a particular host x.x.x.x through wan1. I used the below option in my router. But I am able to ping x.x.x.x even my wan1 link is down.

/ip route
add dst-address=208.67.222.222/32 gateway=gateway wan1
It's because gatewaywan1 becomes unreachable and you ping passing through default route that is active.
Look for recursive routing in MK Wiki, you don't even need netwatch to failover.

If you make for example dst-address=8.8.8.8 gateway=wanIP scope=10 and then dst-address=0.0.0.0/0 gateway=8.8.8.8 check-gateway=ping the default route becomes recursive and if you don't ping 8.8.8.8 the default route becomes inactive
 
AnupamPradhan
newbie
Topic Author
Posts: 35
Joined: Wed May 04, 2016 2:44 pm

Re: Static route not working

Mon Dec 03, 2018 9:37 pm

I tried a lot of thing for failover. But nothing seems to be work perfectly. can you suggest something which will work perfectly?
 
Redmor
Member Candidate
Member Candidate
Posts: 256
Joined: Wed May 31, 2017 7:40 pm
Location: Italy

Re: Static route not working

Tue Dec 04, 2018 8:57 am

I tried a lot of thing for failover. But nothing seems to be work perfectly. can you suggest something which will work perfectly?
Recursive routing as I suggested in previous post.

Who is online

Users browsing this forum: pizzydmgm and 55 guests