Page 1 of 1

Netwatch WAN failover with dynamic gateway

Posted: Thu Oct 25, 2018 8:08 pm
by adroman
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:

Re: Netwatch WAN failover with dynamic gateway

Posted: Thu Oct 25, 2018 8:25 pm
by AlainCasault
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


Re: Netwatch WAN failover with dynamic gateway

Posted: Thu Oct 25, 2018 11:12 pm
by adroman
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

Re: Netwatch WAN failover with dynamic gateway  [SOLVED]

Posted: Fri Oct 26, 2018 3:25 am
by AlainCasault
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


Re: Netwatch WAN failover with dynamic gateway

Posted: Fri Oct 26, 2018 5:50 am
by adroman
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)

Re: Netwatch WAN failover with dynamic gateway

Posted: Wed Oct 31, 2018 5:22 am
by adroman
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

Re: Netwatch WAN failover with dynamic gateway

Posted: Wed Oct 31, 2018 12:50 pm
by AlainCasault
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