Saturday, September 15, 2012

Dynamic Dns on an Edgewater Edgemarc device

Edgewater Networks makes some decent VOIP routers.  I've used then for some time now in various situations, and always when configuring a network that uses hosted VOIP. One thing that all router manufacturers seem to do (rather poorly) is supply a Dynamic DNS feature.  Edgewater is no exception, since they hard code a few providers, and almost none of them work or are now paid.  I needed to use Name Cheap's excellent Dynamic DNS service. Well it's no secret that Edgewater's VOS is Linux with Busybox providing all the standard shell apps and utilities.  It also has a crontab and wget, so problem 99.9% solved!

First, know that you have to have SSH console access to the Edgemarc.  Once you get logged in, you are in a very minimal BusyBox shell, so vi will be stripped of almost all usefulness, so we'll just cat what we need.  First, copy this block into your favorite editor, and edit to format it to the values you need, or another DDNS provider's format altogether.  Then let's create a shell script that we'll call via a cron job once an hour to update our IP address.  Note that the filesytem is read only except for a few directories.  /etc/config is one of them.

1:  # cd /etc/config   
2:  cat > /etc/config/ << EOF  
3:  #! /bin/sh  
4:  #namecheap dynamic dns:  
5:  wget --no-check-certificate -O /tmp/dyndns \  
6:  "[YOUR-HOST]&domain=[YOUR-DOMAIN]&password=[YOUR-DDNS-PASSWORD]"  
7:  EOF  

Now, let's test it:
chmod a+x /etc/config/
cat /tmp/dyndns

Does it work?  If so, let's schedule it via cron.  Let's do some more cat magic:
cp /etc/config/crontab /etc/config/crontab.sav
cat >> /etc/config/crontab << EOF
* */1 * * * root /etc/config/

Now you should have a crontab that runs this script once an hour, and grabs the output of the POST and writes it to /tmp/dyndns.  You can check that file every once in a while to see that everything is working.

Have fun hacking your Edgemarc!