DDNS: Accessing Your LAN When Your IP Changes

DDNS: Dynamic Domain Name Service

Few of us can afford a fixed IP address to run a small publicaly available website or to maintain a WireGuard VPN server to enable connection when away from home. A typical residential IP address can change unpredictably depending on the internet provider's policies, system reboots, etc.

There are free Dynamic Domain Name Service DDNS providers. A few steps are needed to take advantage of DDNS. FreeDNS and paid accounts are available.

  1. Open an account with a DDNS provider. FreeDNS
  2. Choose a domain name from their offerings or bring your own.
  3. Tell them your current IP address and the port which is open.
  4. Configure your modem/router to open a port to your server
  5. If your IP address changes, update your IP address.

Updating your IP address can be done by running a cron job periodically. Free DNS asks that you only update your IP address when it actually changes. FreeDNS has example php and bash scripts using curl, wget and other commands suitable to run as cron jobs. You basically poll your IP address periodically and if it changes, run a script to notify the DDNS provider. Windows, Linux and Mac scripts are shown.

Things I learned in trying to get this working. Comcast/Xfinity is my internet provider. They removed the ability to open a port from their modem/router admin page. You now have to use their app on your android or iPhone to open a port. Quite annoying. I suspect I will buy my own DOCSIS modem in the near future and stop renting theirs.