/updateddns

A python script for updating your FreeDNS DDNS IP, with logging. Meant to be used with crontab.

Primary LanguagePythonGNU General Public License v2.0GPL-2.0

This is a python script for updating your FreeDNS account. This can be
adapted for other services by changing the first string in the update_url
variable below.

This program creates/uses a file called ".freedns_ip" in the directory 
of the script. It also creates various log files. Make sure the script 
has read/write access to this directory!

I have implemented cyclical logging, so when the log is full, it gets moved
to log.1, and log.1 gets shifted to log.2, etc. Each log file is 4096 bytes
and there are 7 log file backups. The default logging level is INFO. You can
change that by changing the [.setlevel(INFO)] to [.setlevel(DEBUG)] below,
under the creating logger section and the creating handler section.

I used WTFismyIP.com to fetch the external IP address. You can substitue for
another if you know what you're doing.

This script is free, and licensed under GPL2. It comes with NO warranties or
guarantees, and I have no liabilities. Enjoy.


To Use this script:

Make a directory in your home folder. Normally, you can create a folder 
in your home directory like this:

> mkdir ~/.ddns

Copy this script to that folder.

Get your update key. You can find your FreeDNS update key by logging 
into your freedns account online, and then clicking Dynamic DNS in the 
menu on the left, then at the bottom of the page, right-click Direct URL 
and copy the link.

In the script, find where it says

> update_key = ''

The KEY is everything after the ?, so delete everything up to and 
including the ?. The, put whatever remains between those single 
quotation marks. You can see that the update_url variable builds this 
URL everytime.

Now, add this script to your crontab. You can usually do this via:

> crontab -e

It can be run by referencing its location because I put the shebang at 
the top of the script. You can, however, manually run it via:

> python /path/to/script.py

As an example, this is the line you would add to your crontab:

*/5 * * * * python /home/user/.ddns/updateddns.py

Just replace "user" with your username.