Ham Radio

Identify OpenSPOT local IP on foreign network

This post is part of the series OpenSPOT

Other posts in this series:

  1. Using OpenSPOT On Multiple WiFi Networks
  2. Identify OpenSPOT local IP on foreign network (Current)

Identify OpenSPOT local IP on foreign network

What’s the problem?

Last year I wrote about the OpenSPOT and OpenWRT integration but now I encountered an issue.
When I want to connect it to public WiFi network, I can connect it to my phone’s WiFi first then add the public network name to Travelmate and reboot it.
But, how can I tell what’s the IP of the OpenSPOT so I can control it?
At home, I can check the IP on the router but on public networks I don’t have any way to know the IP (don’t want to scan the network, it takes too much time).


Make OpenWRT send its IP to external service.

I use service called Dweet.io which allows to send messages for IOT devices.
All you need is to send simple HTTP request and send the data you want.

This is the script:

ips=$(ifconfig | awk '/inet addr/{print substr($2,6)}')
ip1=$(echo $ips | cut -d' ' -f1)
ip2=$(echo $ips | cut -d' ' -f2)
ip3=$(echo $ips | cut -d' ' -f3)
echo $ip1
echo $ip2
echo $ip3
wget -O/dev/null "http://dweet.io/dweet/for/YOUR-NAME?ip1=$ip1&ip2=$ip2&ip3=$ip3"

Quick explanation:

  1. The script gets the IP from the system.
  2. Slice the IPs to different variables.
  3. Print the IPs to the user for debugging.
  4. Send the data to Dweet.
Showing the IP on the Android WiFi via Dweet.io JSON

Usually only the last IP is what you need but I decided to leave all of them.
You’ll need to change the YOUR-NAME to unique name.
Then copy the script to /etc/hotplug.d/iface
And change the permissions: chmod +x dweet.sh

Later, I built simple web page to show me the IPs.

If you’re a programmer you probably wonder why not using CURL?
That’s because I wanted to use native OpenWRT tools and it doesn’t include CURL right out of the box.
Actually, I have 127kb left on OpenWRT so I had some limits 🙂


Did you like it?

Leave a Comment

Your email address will not be published. Required fields are marked *

Skip to content