Community discussions

MikroTik App
 
User avatar
jibanes
newbie
Topic Author
Posts: 30
Joined: Sun Mar 25, 2012 8:13 am

Dynamic wireguard peer address

Fri Jun 09, 2023 7:57 am

Hello there,

I have two mikrotik routers on 7.9.2 in two different locations with wireguard setup.
each location also has ddns-enabled (/ip cloud set ddns-enabled=yes ddns-update-interval=1m)

Here is one of my peers, I have removed some of the sensitive information:
/interface wireguard peers
add allowed-address=192.168.0.0/24 endpoint-address=1.2.3.4 endpoint-port=13231 interface=wireguard1 public-key="blah"
The problem here is that the ip address of the other location is subject to change, and adding a peer doesn't allow me to specify an address list; how could I dynamically keep the endpoint-address of the other location sync'd with the other location's ddns name (i.e. qwerty.sn.mynetname.net)

Thank you!
 
gabacho4
Member
Member
Posts: 331
Joined: Mon Dec 28, 2020 12:30 pm
Location: Earth

Re: Dynamic wireguard peer address

Fri Jun 09, 2023 8:42 am

Just use the ddns host as the IP address. You can use a fqdn. So, client.dn.mynetname.net will work just fine. Set a keep alive for like 30 seconds. Easy peasy. The ddns will perform a check every 30 minutes unlesd you changed the setting. I'd probably recommend like 5 to 10 minutes instead.

Only warning is that the Mikrotik ddns service seems to crash sometimes which will result in you being unable to connect if your connection is reset during that time. For this reason I have a script that runs every few minutes and updates a Google domains ddns A record that I use instead. But the idea is exactly the same.
 
User avatar
jibanes
newbie
Topic Author
Posts: 30
Joined: Sun Mar 25, 2012 8:13 am

Re: Dynamic wireguard peer address

Fri Jun 09, 2023 8:45 am

Oh how did I not think of this!
yeah it's okay if I lose network from time to time I think, but I like your idea of doing it via a google ddns as well
 
gabacho4
Member
Member
Posts: 331
Joined: Mon Dec 28, 2020 12:30 pm
Location: Earth

Re: Dynamic wireguard peer address

Fri Jun 09, 2023 12:17 pm

Glad to be of help. Sometimes we all need a little nudge in the right direction. I've had many a "lightbulb" moment in the course of my networking adventure.

Who is online

Users browsing this forum: Google [Bot], guemat, jaclaz, uxertxo, Wlad3 and 44 guests