Community discussions

MikroTik App
 
MrSerio
newbie
Topic Author
Posts: 26
Joined: Tue Feb 15, 2022 10:17 pm

Force ZeroTier over specific Internet/WAN connection

Sat Dec 23, 2023 11:23 pm

Hi Everyone,

We've recently done a deployment that involves ZeroTier, and a dual ISP set-up. The two ISP's at the customer are configured for fail-over (both default routes for both ISP's are configured, both with check-gateway, one with a lower weight than the other).

Currently ZeroTier connects, as expected over the active/primary ISP. However customer wants ZeroTier to use the back-up ISP.

We've tried the interface option under the instance menu, by default this is set to "ALL". When we configure this for the interface connected to the back-up ISP ZeroTier is unable to connect. Only when I disconnect the primary ISP will it work over the back-up ISP. If I configure the ZeroTier instance interface to the interface of the primary ISP (assuming both ISP's are active) the connection also remains online.

In other words, ZeroTier will only use the default route to connect to the internet.

Is there a way I can force ZeroTier to work over the secondary/back-up ISP?
 
User avatar
loloski
Member
Member
Posts: 354
Joined: Mon Mar 15, 2021 9:10 pm

Re: Force ZeroTier over specific Internet/WAN connection

Sun Dec 24, 2023 1:58 am

you can try to use mangle output and routing mark to make host outbound traffic of the router to go on specific ISP on udp port 9993
/ip firewall mangle
add action=mark-routing chain=output dst-port=9993 new-routing-mark=UG3 passthrough=no protocol=udp
 
MrSerio
newbie
Topic Author
Posts: 26
Joined: Tue Feb 15, 2022 10:17 pm

Re: Force ZeroTier over specific Internet/WAN connection

Sun Dec 24, 2023 5:38 pm

Your suggestions sounds logical, I expected that'd do it. However it appears not to do much, although I do see some ZT traffic through the secondary ISP, which wasn't the case previously.

I've made some adaptations:
  • I've changed DST/9993 to SRC/9993 for the mangle rules
  • I hadded a second mangle rule as prerouting, I see more traffic going through that one compared to the output rule
I challange I see is that although UDP/9993 is default most peers use other random UDP ports.

Still open to suggestions/improvements.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5508
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: Force ZeroTier over specific Internet/WAN connection

Sun Dec 24, 2023 8:42 pm

Use zerotier interface instead of ports for mangle.
That way you got them all.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3591
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Force ZeroTier over specific Internet/WAN connection

Sun Dec 24, 2023 10:22 pm

Use zerotier interface instead of ports for mangle.
That's not right...

The interface is the inner tunnel traffic (e.g. "zerotier1" - the ZeroTier network/"LAN") - so that not where routing/NAT is going wrong here. It's the "outer" vt1 instance tunnels (e.g. VL1 tunnels to "peers") the OP want going out a specific WAN & these ("zt1" etc) are NOT selectable as in "interface" in firewall. Now... using port to identify isn't great either since there is NO guarantee ZT will always use port 9993 (although it the first it tries, but not only method)...

In theory, the default NAT WAN rule should work if the secondary WAN was selected at the ZT instance. So that's kinda weird here. Also, ZT will use IPv6 FIRST... so if that's enabled that's what's going to be used BEFORE IPv4 things.

Perhaps the config help figure this out. I think you may need to routing tables/rules, in addition to basic failover just using distance= on default routes.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5508
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: Force ZeroTier over specific Internet/WAN connection

Sun Dec 24, 2023 11:24 pm

You're the ZT master 8)
 
User avatar
loloski
Member
Member
Posts: 354
Joined: Mon Mar 15, 2021 9:10 pm

Re: Force ZeroTier over specific Internet/WAN connection

Mon Dec 25, 2023 1:00 am

as a last resort though it's not the _real_ solution he/she could install zerotier in the other device using his/her 2nd ISP as a next-hop then use ROMON if the purpose of this zerotier is just for management purposes no more fiddling with mangle :)
 
MrSerio
newbie
Topic Author
Posts: 26
Joined: Tue Feb 15, 2022 10:17 pm

Re: Force ZeroTier over specific Internet/WAN connection

Tue Dec 26, 2023 7:03 pm

For my understanding, if the instance on the MT router is listening om UDP/9993, this is before NAT or after NAT? Hence if I use a mangle rule to mark all packets/connections originating from this UDP/9993, this should work? (although I believe I've already observed that it doesn't)

Who is online

Users browsing this forum: No registered users and 5 guests