Keeping your domain name updated

From freebsd.xn--wesstrm-f1a.se

Jump to: navigation, search

Overview

To easily be able to access the services on the router from the Internet, it's important that the domain name is constantly updated with your current external IP address whenever it changes. In the FreeBSD Ports Collection there is a small client called Ipcheck that you can run with a crontab job to accomplish this automatically. If you have a static IP address, this is of no concern to you and you can skip this guide.

Instructions

First compile the client:

# cd /usr/ports/dns/ipcheck
# make
Python.png
Ipcheck is dependent on the Python programming language and you will be given the opportunity to change its compilation options. The defaults are fine so simply highlight OK and press Enter. Python will take a while to compile but it's a popular script language these days and it doesn't hurt to have it installed. If no errors are reported, you can install the compiled binaries.
# make install clean

You have to run Ipcheck manually once to create the configuration file that will store your DynDNS username and password. In the command below, make sure you exchange userid and password for your own. The interface listed should be the name of your router's external interface and the domain must of course be the one you are using yourself.

# cd /usr/local/etc
# /usr/local/bin/ipcheck.py --makedat -w -l -i em1 userid password pp.dyndns.biz
ipcheck.py: pp.dyndns.biz good 85.226.59.44 -update successful

Edit root's crontab.

# setenv EDITOR ee
# crontab -e

Add the following line to crontab to have Ipcheck run automatically once every minute. It isn't possible to run anything more frequent than that when using cron and care should be taken when deciding what jobs to run this often. Ipcheck will only make an update if it finds that the IP address has changed since the last time it checked. It will also force an update after 25 days to prevent your domain from becoming removed from DynDNS.

* * * * * cd /usr/local/etc ; /usr/local/bin/ipcheck.py -w -l -i em1 userid password pp.dyndns.biz

As before you make sure the external interface, userid, password and domain match your own.

Note: I've found one small quirk with Ipcheck. Debugging the script it appears it never actually performs a DNS lookup to check the current name resolution of the domain. It only compares the current IP of the router with the value stored in a local file from the last update. If for some reason your domain gets updated from another computer with another IP, Ipcheck won't catch this and you will have to forcefully update it with the -f parameter or through the web interface at DynDNS.


Next guide: Keeping the correct time
Personal tools