Skip to main content Can I put domain name in [Peer]->Endpoint in wg.conf? : r/WireGuard

Can I put domain name in [Peer]->Endpoint in wg.conf?

# eva_xiaomi_notebook client
[Interface]
PrivateKey = 888888888888888888888888888888888
Address = 10.0.0.3/24
DNS = 1.1.1.1

[Peer]
PublicKey = ddddddddddddddddddddddddddddddddddddddddddddddd
Endpoint = 188.225.25.237:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 0

For example if I host a wg server on home nas with dynamic ip, I sure can create DynDNS(duckDNS)

But can I use this domain name as Endpoint?

Apple Card is a no-fee credit card that gives you up to 3% unlimited Daily Cash back on all of your purchases. Apply now and use right away. Terms apply.
Thumbnail image: Apple Card is a no-fee credit card that gives you up to 3% unlimited Daily Cash back on all of your purchases. Apply now and use right away. Terms apply.
Sort by:
Best
Open comment sort options

I do.

I also use the same pubkey.

Yes, you can replace the IP address with a FQDN

Note if the IP of that FQDN changes you will have to turn the tunnel off and reactivate it as once the domain name is resolved by wireguard it will not be resolved and since wire guard has no concept of a actual connection It will simply stop working if the IP for that name changes while you're in the middle of using it until you restart the tunnel.

There is a script for doing this in a way that doesn't tear down the tunnel.
https://github.com/WireGuard/wireguard-tools/blob/master/contrib/reresolve-dns/reresolve-dns.sh

You can make runtime changes to wireguard... so you can leave the tunnel up and just change the endpoint.

More replies