Community discussions

MikroTik App
 
adroman
just joined
Topic Author
Posts: 15
Joined: Tue May 29, 2018 3:54 pm

Netwatch WAN failover with dynamic gateway

Thu Oct 25, 2018 8:08 pm

Hello guys!

I have netwatch failover configuration for my WAN, but one of my ISPs has dynamic gateway that I get from DHCP.
And sometimes when router is powered off for hour or more - my default gateway may change and my default static route that I use for netwatch becomes unreachable.
Please help me with workaround to this issue.

I just cannot figure it out... :shock:
 
User avatar
AlainCasault
Trainer
Trainer
Posts: 632
Joined: Fri Apr 30, 2010 3:25 pm
Location: Prévost, QC, Canada
Contact:

Re: Netwatch WAN failover with dynamic gateway

Thu Oct 25, 2018 8:25 pm

Hello

I guess you could script a dhcp client renewal and schedule it every so often, frequency is up to you.

I'm not a scripting expert, so I won't suggest one ;) but I'm pretty sure it would be ok.

Regards,


Sent from Tapatalk

 
adroman
just joined
Topic Author
Posts: 15
Joined: Tue May 29, 2018 3:54 pm

Re: Netwatch WAN failover with dynamic gateway

Thu Oct 25, 2018 11:12 pm

Thanx for the answer my friend but script for DHCP renewal will be pointless because:
1) DHCP client renews IP address pretty fast by itself
2) Netwatch don't use DHCP automatic default route from DHCP client, it can use only static routes that has to be added manually to get option to add Comment (Comments can't be added to dynamic route from DHCP client).

Here is an example of my netwatch basic WAN failover script:
1) for UP interface
/ip route set [find comment="ISP1"] disabled=no
/ip route set [find comment="ISP2"] disabled=yes

2) and vise versa for Down interface
/ip route set [find comment="ISP1"] disabled=yes
/ip route set [find comment="ISP2"] disabled=no

So this is real brain-twister how to make it work
 
User avatar
AlainCasault
Trainer
Trainer
Posts: 632
Joined: Fri Apr 30, 2010 3:25 pm
Location: Prévost, QC, Canada
Contact:

Re: Netwatch WAN failover with dynamic gateway  [SOLVED]

Fri Oct 26, 2018 3:25 am

Well, this sucks. How can you have something solid when your provider changes stuff. It's the first time I hear about a setup like that.

I wanted to suggest this : https://alaincasault.com/ca/posts

But that setup won't do it either since the default gateway will change on you.

Use my idea of renewing leases. Then, with the new default gateway values, recreate the netwatch entries with your failover scripts.
* dhcp client renew
* recreate netwatch entries
* Netwatch runs

That way, we're both right.

:D


Sent from Tapatalk

 
adroman
just joined
Topic Author
Posts: 15
Joined: Tue May 29, 2018 3:54 pm

Re: Netwatch WAN failover with dynamic gateway

Fri Oct 26, 2018 5:50 am

Plz help :)
I was trying to create a script below, but it doesn't work... I think I have crucial errors (in simple script) ....

:local currentGateway [/ip dhcp-client get value-name=gateway number=0]
(HERE WE GET NEW DHCP GATEWAY)
:local existingGateway [/ip route get number=1 value-name=gateway]
(HERE WE GET EXISTING GATEWAY)
:if ($currentGateway != $existingGateway) do={
(HERE WE COMPARE THESE GATEWAYS)
/ip route set numbers=1 gateway=1=$currentGateway
(HERE WE FIX EXISTING GATEWAY)
} else={
:log info "No route changes needed."
}


(BUT WHY DO NOT WORK?) :shock: :( :? 8)
 
adroman
just joined
Topic Author
Posts: 15
Joined: Tue May 29, 2018 3:54 pm

Re: Netwatch WAN failover with dynamic gateway

Wed Oct 31, 2018 5:22 am

Well, this sucks. How can you have something solid when your provider changes stuff. It's the first time I hear about a setup like that.

I wanted to suggest this : https://alaincasault.com/ca/posts

But that setup won't do it either since the default gateway will change on you.

Use my idea of renewing leases. Then, with the new default gateway values, recreate the netwatch entries with your failover scripts.
* dhcp client renew
* recreate netwatch entries
* Netwatch runs

That way, we're both right.

:D


Sent from Tapatalk
Thanks I've read all your suggested topics and finally figured it out
 
User avatar
AlainCasault
Trainer
Trainer
Posts: 632
Joined: Fri Apr 30, 2010 3:25 pm
Location: Prévost, QC, Canada
Contact:

Re: Netwatch WAN failover with dynamic gateway

Wed Oct 31, 2018 12:50 pm

Well, this sucks. How can you have something solid when your provider changes stuff. It's the first time I hear about a setup like that.

I wanted to suggest this : https://alaincasault.com/ca/posts

But that setup won't do it either since the default gateway will change on you.

Use my idea of renewing leases. Then, with the new default gateway values, recreate the netwatch entries with your failover scripts.
* dhcp client renew
* recreate netwatch entries
* Netwatch runs

That way, we're both right.

:D


Sent from Tapatalk
Thanks I've read all your suggested topics and finally figured it out
Please share :)

Sent from Tapatalk

Who is online

Users browsing this forum: No registered users and 40 guests