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/dyndns.sh << EOF  
3:  #! /bin/sh  
4:  #namecheap dynamic dns:  
5:  wget --no-check-certificate -O /tmp/dyndns \  
6:  "https://dynamicdns.park-your-domain.com/update?host=[YOUR-HOST]&domain=[YOUR-DOMAIN]&password=[YOUR-DDNS-PASSWORD]"  
7:  EOF  

Now, let's test it:
chmod a+x /etc/config/dyndsn.sh
/etc/config/dyndns.sh
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/dyndns.sh
EOF

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!