A quick way for FreePBX/Elastix/Trixbox users to auto-update Dyndns, maybe

Note: This article was updated on June 23, 2006 and again on January 2, 2009 to fix few minor errors, to provide a working location for the inadyn program, and to attempt to clarify things a bit more. Note that it’s written primarily for people that know how to get around in Windows but who may not really be comfortable using the Linux command line to perform tasks. If you feel that everyone who touches a Linux system should be intimately familiar with the Linux command line, this article is NOT for you (in fact, this BLOG is probably not for you)!

If you have installed Asterisk@Home (or, as it’s now known, Trixbox) on a ‘net connection where your IP address can change at will (which is what you generally get if you have you Asterisk box installed at home), and particularly if you installed it using one of the guides at the Nerd Vittles site, then more than likely you got a free account with Dyndns.org to keep the address you give to the world pointed to your real numeric IP address. But, you may have had the problem of keeping Dyndns updated. They don’t like it if you send updates too often, but at the same time, if you don’t send an update every 28 days (even if your address hasn’t changed) they send you a warning e-mail, and give you only a few days to verify your IP address or your Dyndns address stops working. People do miss that warning e-mail for various reasons, only to find that one day neither they nor anyone else can get into their Asterisk box from a remote location. It’s really bad if this happens while you’re on vacation and trying to use a softphone on a laptop to access your Asterisk system.

Some routers actually have Dyndns.org update capability built in and in some cases it even works. Sometimes it works when the IP address actually changes, but doesn’t send an update every 28 days if the IP address doesn’t change.

Now you may be surprised to find out that Asterisk@Home (and perhaps Trixbox, though I haven’t checked) actually comes with an updater program. However, it is not enabled by default, and if you try to get it working you will see why. It works great, except for the fact that it sends Dyndns your internal IP address (192.168.x.x or whatever), which is clearly useless to anyone trying to contact your server from outside your local network. Furthermore, the documentation for this software is nearly non-existent. More power to you if you can get it working correctly, but we couldn’t. It’s ironically named ez-ipupdate, should you have some desire to actually try to make it work.

After spending far too much time trying to coax that into working, we went another route and installed what appears to be a much better program called inadyn. This is pretty easy to install, even if you can’t seem to get anything to install and work under Linux (believe me, I know the feeling). So here’s the process:

cd /tmp
wget http://mi-telecom.org/inadyn.v1.96.2.zip

The above should get you the latest (1.96.2) executable. Note that the original site, inadyn.ina-tech.net, seems to have been shut down, so this link is to a copy on another server. If, for some reason, that link doesn’t work, use Google to search for a copy of “inadyn.v1.96.2.zip” (include the quotes for best results).

Now go into Midnight Commander:

mc -a

The left pane should be showing the /tmp directory. Double click on the file you just downloaded and it should open up and show the directories inside (we do it this way because we want to put the files in different places than what a normal tar command would). Double click on the /inadyn directory, then the /bin directory, then /linux, and you should now see the inadyn executable.

Now use the tab key to move to the right panel and navigate to the /usr/bin directory. Tab back to the left panel and use the up/down arrow keys or the right mouse button (either should work) to highlight the inadyn file, then click on “copy” (pressing F5 should also work) and when the dialog box pops up offering to copy the file to /usr/bin, click OK.

Now you will want to check the permissions of the file you just copied. Tab over to the panel showing the /usr/bin directory, use the arrow keys or right mouse button to select the inadyn file you just copied, and then click on File in the top menu bar – you’ll see the options for checking ownership and permissions. We generally like to use Advanced chown but you may prefer one of the other options. If you plan to run inadyn as root (which is probably what you’ll want to do), then make sure that owner and group have read and execute access (r and x should be showing in the owner and group permissions – the x is especially important since the program won’t run if it isn’t set), then set both owner and group to root.

If you’re new to Midnight Commander and have managed to get into Advanced chown but can’t figure out how to actually change settings, here’s a tip: You can use the tab key to move between fields in order to make changes. Once you are in a permissions field, just type the character you want to toggle on or off – for example if you see a hyphen instead of an x, type an x and it will turn on (or if it’s on and you don’t want it to be, type x to turn it off). Your choices are r for read, w for write, and x for execute. With the ownership fields, once you have tabbed into one of them, you can hit the Enter key and it will show you a drop-down list of possible owners – use the up and/or down arrow keys to highlight the one you want (root in this case), then hit Enter again. Once you have made all the changes you want, click on Set. Caution – resist the temptation to use the mouse to click on other fields in Advanced chown. because doing so may close the Advanced chown window and lose any changes you’ve made. Use the tab and arrow keys to navigate, and only click on Set (or tab to Set and hit Enter) when you are really finished making changes.

Now that you know how to navigate in Midnight Commander and copy a file from an archive, back out of the directory in the left hand panel until you get back to where you see the bin and man directories. Double click on man and you will see two man files, inadyn.8 and inadyn,conf.5. Copy these to files to the appropriate manual directories:

inadyn8 to /usr/share/man/man8
inadyn.conf.5 to /usr/share/man/man5

As for the readme.html file, copy that to any place that is accessible to your web browser – you could put it in /var/www/html temporarily, or you could move it to another box – I’m assuming anyone that can set up Trixbox or Asterisk@Home knows what to do with a .html file. It’s only for you to read; it’s not used in any way by the inadyn program.

Finally, navigate to the /etc directory (while still in Midnight Commander). Midnight Commander doesn’t seem to give you an easy way to create a new text file so while the highlight bar is somewhere in the /etc directory, type

touch inadyn.conf

(What you type should appear on the command line below the two panels). Then press Enter. Now scroll to the file you just created (presently a zero-length file) and click on “Edit” or press F4. Midnight Commander’s text editor window should come up.

Enter these lines as shown except for the italicized portions, which you’ll need to fill in with information from your own Dyndns account:

username username
password password
alias yourdomain.dyndns.org
update_period_sec 300
forced_update_period 2419200
verbose 2
syslog
background

Notes on the above: username, password, and alias are from your account at Dyndns.org. The forced_update_period is 28 days, expressed in seconds, which is Dyndns’ preferred update period. verbose can be omitted or set to anything from 0-5, depending on how much verbosity you want in the system log. syslog causes log entries to go to the default system log (/var/log/messages), alternately you could use something like

log_file /var/log/inadyn.log

to let inadyn have its own log file. But don’t use both the log_file AND syslog options. Finally, background causes the process to run in the background, which is what you want.

There are other options you can use but if you do, you are on your own. Type

man inadyn

from a command line to see all the options, or read the aforementioned readme.html file.

When you’ve entered the above lines into the formerly empty inadyn.conf file, save it and exit back to the main Midnight Commander window (F10 should exit Midnight Commander’s editor). Check that the conf file is no longer zero bytes (so you know it was saved properly). If you want to check permissions or ownership, highlight the inadyn.conf file (if it isn’t already) and then click on File in the top menu bar, then Advanced chown. Usually touch will create the file so that everybody has read access; this may or may not be what you want depending on your ideas about security. If you plan to run inadyn as root, then there’s no reason that anyone else needs to be able to see the .conf file, so set the user and group to root, and give rw access to the owner only, and no access to anyone else.

Watch the log file (/var/log/messages if you’re using the system log) – the first time you run inadyn it should do one update and after that it should not do any updates until your IP address changes, or 28 days has passed. It should detect IP address changes within five minutes.

This assumes you are not in the habit of rebooting your system frequently. One thing I haven’t been able to determine yet is whether inadyn always sends an update upon startup. If it does, then you don’t want to frequently start and stop it because that might trigger Dyndns’ abuse detector. However if you are the typical Linux user that only reboots your machine once in a blue moon, then you could add inadyn to your startup script so it starts automatically after a reboot. To do that, use Webmin. Log into Webmin and then click on the System button, then Bootup and Shutdown, then Create a new bootup and shutdown action. In the Name field, put inadyn; in Description put something like check and update your IP to dynamic DNS Server such as dyndns.org; and in Bootup Commands simply put inadyn. Leave Shutdown Commands empty and make sure Yes is selected for Start at boot time?. Then click Create.

Now the caveat: I’ve only set this up twice, so I’m not saying that this will work perfectly, but if you have any problems or issues please post a comment and maybe someone will be able to advise you. However I wanted to get this posted because inadyn was the only client I could find that would do this that didn’t require an advanced degree in Linux administration to install. No compiling required, just move the binary to an appropriate directory, put a few lines in a config file and it works. Why can’t all Linux software be at least this easy to install? As long as I don’t have to compile anything, I’m happy!

Just remember that if YOU follow what I’ve done here, you do so at your own risk. It might work great, it might not (which is why I put the word “maybe” in the headline). Comments are welcome; let me know if this works for you.

2 Comments »

  1. Anonymous said

    If you use this with no-ip.com service, you need this line in your config:

    dyndns_system default@no-ip.com

    Hope this helps!

  2. [...] as “a free, small, easy portable DynDNS client”, and which was the subject of a previous article on this site. I didn’t install that on my Mac, but I did install wget, because so many [...]

RSS feed for comments on this post · TrackBack URI

Leave a Comment