OpenWRT, DynDNS & ez-ipupdate behind a router
| March 4th, 2007So I have an Openwrt install and wanted to use ez-ipupdate to update my DynDNS account however it would only send the IP of the wlan0 and since I’m behind a router already the IP on wlan0 is for my LAN. So I made a quick hack to get the internet IP I wanted to DynDNS. Here it is.
First off I had to figure out the real IP. For this I abuse a web site called whatismyip.com by dumping the text into awk, ripping out the IP and exporting the variable $IP.
I did this by adding this to the top of /etc/init.d/S95custom-user-startup:
for myip in `links -dump http://whatismyip.com | awk '/ Your IP Is/{print $NF}'`
do
export IP=$myip
done
Then I had to turn off demon mode of ez-ipupdate in /etc/init.d/S52ez-ipupdate
Find this line:
/usr/sbin/ez-ipupdate -d -F $PID_F -c $ddns_conf -b $ddns_cache -i $wan_interface -e $ddns_exec_ok
Change it to:
/usr/sbin/ez-ipupdate -a $IP -F $PID_F -c $ddns_conf -b $ddns_cache -e $ddns_exec_ok
Please note the addition of the “-a $IP” above. This is where we pass the real IP to ez-ipupdate.
Then I added this line to /etc/init.d/S95custom-user-startup to restart the ez-ipupdate after the $IP variable has been passed.
/etc/init.d/S52ez-ipupdate restart
Then I added a cron job that checks and updates the IP every half hour.
crontab -e
*/30 * * * * /etc/init.d/S52ez-ipupdate restart
/etc/init.d/S60cron restart
Reboot the router and your DynDNS IP should get updated! w00t!

http://checkip.dyndns.org
just a note:
http://whatismyip.com/automation/n09230945.asp
will spit out just the IP now.
So you could loose the awk like this:
for myip in `links -dump http://whatismyip.com/automation/n09230945.asp`