I have recently changed my ISP and the new one is providing me an IP address through PPPoE that’s changing after every disconnect.
Being in this situation I had two options: set up a dynamic DNS client on my router using a dynamic DNS service such as no-ip.com or use my current DNS server and automatically update its zone records. I decided to go for the latter.
The mechanism I will use is pretty simple: a client inside my LAN will periodically initiate an HTTP request to a particular section of this website that is password protected. The web server I am running remote-lab.net on is also the authoritative name server of remote-lab.net. The server will run a script every couple of minutes that checks the source IP address of completed HTTP requests, it will update the zone file records and increment the zone’s serial number.
First, let’s install the required servers: Bind9 DNS server and Apache HTTP server:
By default Apache’s default DocumentRoot is placed in /var/www. Let’s create a section inside it that is password protected:
Now let’s try a test that sends an HTTP request and see if the server returns a 200 OK.
Check the apache logs:
Setting up the DNS server. I will use bind9 and show the config files used for remote-lab.net domain as example:
Create the zone file of your domain:
One thing to notice is that I set the TTL value to 3 minutes so that the changes will be quickly propagated.
virtual.remote-lab.net is the hostname assigned to my lab ip address.
Edit the named.conf.local file and add your zone to the config :
Restart the server and it should be up and running. You can do a quick test by querying the server for a specific record:
Create a bash script that checks the web server logs, updates the zone records based on the source IP address of the HTTP requests and sends you an email when a change occurs:
The last thing to do is to add our script to the cron jobs and run every several minutes.
Please let me know if you have any questions or if I missed something in this setup.