WireGuard VPN on DD-WRT router with dynamic IP

Be always at home

Posted by Giulio Magnifico on Tuesday, August 3, 2021

WireGuard is a great network tunnel/VPN, very fast and reliable, but for me it has one downside: I have to update the config file every time I reboot my router or modem, because the IP from my ISP change every time. So I solved this trouble using a dynamic DNS service provider (in my case noIP), so now every time the router/modem change the WAN IP, my iPhone and Macbook change the WireGuard configuration and they can connect automatically to the new IP of my home router and I’m connected to my home LAN plus I can use my Pi-Hole adblocker also via mobile or outside my home. First of all you need a router flashed with DD-WRT, then activate the WireGuard tunnel with your configs, here’s mine:

VPN config

Then you need to go to noip.com and create your free account and your Hostname. Now back on the router Tunnels interface and click on “Export Peer Config” (no the QR doesn’t work for this), and open the “wireguard_config_oet1_peer0.conf” with your editor and add your noIP hostname instead of the router WAN IP endpoint:

[Interface]
    Address = 10.4.0.6/0
    PrivateKey=
    ListenPort = 51820
    DNS = 192.168.1.4
    MTU = 1432
 [Peer]
    PublicKey= 
    Endpoint = yourhostname:51820 
    AllowedIPs = 0.0.0.0/0
    PersistentKeepalive = 25

After done it, just go back to your router and under the setup->DDNS you can add your service and configure it with your hostname, example:

DDNS page

Now import you wireguard.conf file into your WireGuard iPhone app or where you want, and automatically the router will send your new IP address to the noIP hostname and WireGuard tunnel will automatically works “forever”.

This is the .conf when opened in WireGuard

Wireguard iPhone

But remember that if you’re on a free plane of noIP, you have to change your hostname every 30 days. To avoid this annoyance (and have other benefits) you can purchase the 20$/year plan. If change the hostname every month don’t bother you, then stay on the free plan.