connecting Wireguard client to a Wireguard server with a non-fixed IP address

Consider the following scenario: You want to connect a client to a server via Wireguard – the server’s IP address changes regularly. Further you want to contact the client from the server (so not the standard use-case) – you will also have to add a keep-alive to the client config.

The keep-alive is easy, just edit the client config and add “PersistentKeepalive = 25”:

cat /etc/wireguard/wg0.conf

[Interface]
PrivateKey = myprivatekey
Address = 10.66.66.4/32
DNS = 1.1.1.1

[Peer]
PublicKey = mypublickey
AllowedIPs = 10.66.66.0/24, 192.168.178.0/24
Endpoint = domain.net:50121
PersistentKeepalive = 25

 


 

To connect to an endpoint with a changing IP, this is documented in the Arch Linux wiki:

https://wiki.archlinux.org/title/WireGuard#Endpoint_with_changing_IP

You have to install wireguard-tools first to get all relevant config files to your machine.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *