Community discussions

MikroTik App
 
Josephny
Member
Member
Topic Author
Posts: 495
Joined: Tue Sep 20, 2022 12:11 am

Wireguard DNS re-resolution script

Tue Apr 02, 2024 1:37 pm

I've had the script below (reload the endpoint's DNS) set in scheduler to run every 30 minutes.

Lately I've noticed that the "if...do" is triggered (i.e., the "if" resolves to "yes") every time the script is run, despite $LastHandshake being less than 5m. Pretty sure $LastHandshake resolves to ""

I didn't write the script, and I don't understand when $LastHandshake would resolve to ""

Can I just take out the condition: ([:tostr $LastHandshake] = "")

I vaguely remember mention that more recent versions of RouterOS do not need this DNS re-resolve -- and I dreaming this or is it true?

Thanks!

:foreach i in=[/interface/wireguard/peers/find where disabled=no endpoint-address~"[a-z]\$"] do={
  :local LastHandshake [/interface/wireguard/peers/get $i last-handshake]
  :if (([:tostr $LastHandshake] = "") or ($LastHandshake > [:totime "5m"])) do={
   
     :log info "WG-iface-restart script found WG peers with last handshake greater than 5 minutes; then reset the endpoint-address to reload dns of endpoint"

    /interface/wireguard/peers/set $i endpoint-address=[/interface/wireguard/peers/get $i endpoint-address]

   :local endpoint [/interface/wireguard/peers/get $i endpoint-address]
   :log info "WG-iface-restart script found WG peer with last handshake greater than 5 minutes; then reset the endpoint-address to reload dns of endpoint:  $endpoint"

  }
}

 
llamajaja
Member Candidate
Member Candidate
Posts: 198
Joined: Sat Sep 30, 2023 3:11 pm

Re: Wireguard DNS re-resolution script

Tue Apr 02, 2024 8:17 pm

Correct, since maybe 7.12??? not sure when but there is no longer a need to do this on the client (for handshake) peer to re-establish connectivity with the Server ( for handshake ) peer.
 
Josephny
Member
Member
Topic Author
Posts: 495
Joined: Tue Sep 20, 2022 12:11 am

Re: Wireguard DNS re-resolution script

Tue Apr 02, 2024 11:39 pm

So I don't need the script at all, right?
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19680
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Wireguard DNS re-resolution script

Tue Apr 02, 2024 11:46 pm

 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19680
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Wireguard DNS re-resolution script

Tue Apr 02, 2024 11:46 pm

Correct, since maybe 7.12??? not sure when but there is no longer a need to do this on the client (for handshake) peer to re-establish connectivity with the Server ( for handshake ) peer.

Who is online

Users browsing this forum: Idontknow, n0rthking and 41 guests