Getting the current IP address from the Fonera Box

Submitted by matthias hub on Mon, 09/20/2010 - 23:02
I wrote a little script to get the current public IP address from the Fonera status page. In my set up the box has the default internal IP address 192.168.10.1.
Here the full script:

#!/bin/sh
IP_ADDRESS=`wget -q -O - http://192.168.10.1/cgi-bin/status.sh | grep "IP Address" | sed -n '//{p;q;}' | sed 's/.*//' | sed 's///'`
# IP Address:88.130.197.125 if test "`cat /tmp/current-fonera-ip.txt`" = "$IP_ADDRESS"; then
echo "not changed"
else
echo "changed, update"
# do something like dyndns update
wget -q http://user:password@server/nic/update?hostname=hostname.domain.tld echo $IP_ADDRESS > /tmp/current-fonera-ip.txt
fi

(As you see I used it to do a dyndns compatible update. On the server backend this just requires a bind configuration and a simple update script. Maybe I will show that later here.)