Menu

Home

Salvatore Ventura

pyFreeDnsUpdate

pyFreeDnsUpdate is a python script created to keep the FreeDNS record for a list of domains current to the dynamic nature of the IP address of the hosting server.

Requirements

For pyFreeDnsUpdate to run, python 2.x must be available on the system (tested with 2.7.x).
Only non-standard required library is Requests: please refer to their documentation for installation on your OS.

The server must have a current DNS configuration, so that correct DNS lookups can be made locally. Also - and obviously - the server must have internet (or at least HTTP) connectivity out to reach the FreeDNS server.

Installation

Copy pyFreeDnsUpdate.py in a folder on your destination server. Make sure the privileges under which the script will be running has read/write privileges on the current folder, needed for log file creation.

You will then need to edit the script file to specify your domain list and API key. For that, open pyFreeDnsUpdate.py in your favorite editor and find the following section, at the top of the file:

DOMAINS={
         'your.domain.here' : 'your_api_key_here',
}

DEBUG=False

and replace "your.domain.here" with your desired domain, and associate your API key to update the FreeDNS server. If you have multiple entries to update, you can duplicate that line as many times as you need. Save and close the file, then test with a manual run, specified in the next section.

How to run

Manual runs

Make sure you can run python with the user account intended to perform the periodic poll. For that simply login as the desired user, and run:
python pyFreeDnsUpdate.py

If everything is fine, nothing will be printed on screen and a logfile "freednsupdate.log" will be created in the same folder. Check the logfile for errors.

On Windows it is no different, except you may have to specify the full python executable name and/or the path:
python.exe pyFreeDnsUpdate.py

Scheduled runs

On linux, it is very convenient to setup a cron job to run the script. Follow cron documentation for full details and options. As an example you could have this entry in your user's crontab by entering the 'crontab -e' mode:

* * * * * /usr/bin/python /home/salvo/scripts/freednsupdate/pyFreeDnsUpdate.py

which will run the script every minute. Keep in mind, that if local DNS resolution returns the same address as the one detected externally, then no update is performed on the FreeDns server.

On Windows, follow tutorials on how to create scheduled tasks: it's not different.

Troubleshooting

For any troubleshooting, you will need to make sure the following:

  • the script actually runs: python and libraries installed? permissions? paths? typos?
  • you can perform nslookups on the current host (say to yourdomain.com)
  • you can access the internet from the current host
  • the API key is correctly copied in the domain list
  • ADVANCED: in the script, set DEBUG to True, and rerun manually, check/collect the log

Support info

If you are still having troubles, upon contacting me, please provide:

  • script version
  • all the information above
  • description of the issue: what's happening, what's not happening
  • logfile from the latest run(s)
  • ADVANCED: provide the log with DEBUG set to True

NOTE : The script is provided AS-IS: if you edit below the specified line, you are outside of supported land.

Enhancement request

Please email me any requests for enhancements, bugfixes etc.

Project Members:


Monday.com Logo