Hub n Spoke with dynamic IPs on spokes
-
I have a WireGuard VPN connecting a remote site to the main site. The two sites have failover WAN connections so the IPs can change. I have configured these two sites in a hub-n-spoke configuration as the hub's IP is static. I have noticed that the peer IP addresses are in the conf file on the hub which is a problem as these addresses should allow for change and not be hard coded. Is this possible with WireGuard?
My hub conf files is below:
[Interface] Address = 172.16.0.1/24 DNS = 192.168.1.5 SaveConfig = true PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE ListenPort = 51820 PrivateKey = *************************** [Peer] PublicKey = *************************** AllowedIPs = 172.16.0.2/32, 192.168.1.0/24 Endpoint = X.X.X.X:51820 [Peer] PublicKey = *************************** AllowedIPs = 172.16.0.3/32, 192.168.2.0/24 Endpoint = X.X.X.X:51820
Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.