Reply to comment

OpenWRT Router IP Exposure Script

If you have an OpenWRT router (any router that can run the software can be converted), you can do a little quasi-dynamic-DNS trick. This is useful if you don't really care enough to set up Dyn DNS, and you have a web server setup.

The main disadvantage is that you don't have a DNS record. The main advantage is that the updates don't need to propagate through DNS, so if you have an app that relies on talking to your LAN, you can quickly detect any changes.

First, save this as /usr/bin/checkmyip


[ -f /tmp/myip ] &current_ip=`ifconfig | grep P-t-P | tr ':' ' ' | awk '{print $3;}'`

if [ ${past_ip} != ${current_ip} ] ; then
        exec wget -q -O /tmp/myip.html${current_ip} 2>&1 &
        echo ${current_ip} > /tmp/myip
        rm /tmp/myip.html

Then add it to your cron via crontab -e. Run it every 15 minutes, or more often.

Add this to your web server, in its own directory, as wrt.php:

$ip = $_GET['ip'];
$current_ip = escapeshellcmd("$ip");
system("echo $current_ip > current_ip");
system("echo Changed on: `date` >> current_ip");

Yes, not that efficient.


The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

2 + 15 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.