Sunspot Home

See my home webcams when I am away even though
I do not have a static IP address on my home LAN

I tried a free DNS server but they switched off my account. . . . . . .


Use a Linux server on the home LAN to find the current IP address using ifconfig.

Use Blassic basic to extract the IP address as a string and create a webpage for the server.

Upload the webpage (including the current IP address) to the public server using ncftp
The webpage on the public server automatically redirects the user after 1 second to
a menu webpage on the home LAN

The Blassic program

' find the current dynamic IP address and send a web page to an open server on the internet
' (this is a server that holds your public web server files and which anyone can access)
' the page you upload redirects the user to a menu on a server on the home LAN that has a dynamic web address

' the host on the LAN uses a ramdisk for temporary files - create this within the host boot script using -
' mkdir /var/www/ramdisk
' mount -o size=2M -t tmpfs tmpfs /var/www/ramdisk

' the Linux command ifconfig gets lots of text that includes the dynamic IP address
SHELL "echo -n `ifconfig eth0`>/var/www/ramdisk/eth0.txt"
OPEN "/var/www/ramdisk/eth0.txt" FOR INPUT AS #1 : INPUT #1,eth0_all$ : CLOSE #1

' extract the text that starts with the IP address
ipaddress$ = MID$(eth0_all$,61,25)

' find the character B that follows the address in the string
character$ = MID$(ipaddress$,i,1)
IF character$ = "B" THEN length=i :GOTO NextBit
IF I = 18 THEN GOTO NextBit
GOTO New_i


'extract the IP address (remove the space and the B that follow it)
ipaddress$ = LEFT$(ipaddress$, i)

PRINT ipaddress$

' pass the IP address to bash and ask ncftp to send it to the open server on the internet as a text file
OPEN "/var/www/ramdisk/IP_address.txt" FOR OUTPUT AS #1 : PRINT #1,ipaddress$ : CLOSE #1
SHELL "/root/"

' create the the redirection web page - CHR$34 is "
html_top$ = "<html><head><meta http-equiv="+CHR$34+"refresh"+CHR$34+" content="+CHR$34+"1; URL=http://"

html_bottom$ = CHR$34+"></head><body>jump to menu auto</body></html>"
hop_html$ = html_top$+ipaddress$+html_bottom$

PRINT hop_html$

' pass the redirection web page to bash and ask ncftp to send it to the open server on the internet as html
OPEN "/var/www/ramdisk/hop.html" FOR OUTPUT AS #1 : PRINT #1,hop_html$ : CLOSE #1
SHELL "/root/"
' from a browser go to http://my_open_server_address/hop.html
' and it will redirect to the menu page on your LAN

the web page is like this

<html><head><meta http-equiv="refresh" content="1; URL=http://

"></head><body>jump to menu</body></html>

ncftp is used like this -

FTPU="myname" # ftp login name
FTPP="mypassword" # ftp password
FTPS="" # remote ftp server
FTPF="/" # remote ftp server directory for $FTPU & $FTPP
ncftpput -m -u $FTPU -p $FTPP $FTPS $FTPF $LOCALD

Just shows how little about code writing you actually need to know when you have Blassic and Google!

A simple way to show the local home IP address on a public server
thanks to
http ://

FTPU="myloginname" # ftp login name
FTPP="mypassword" # ftp password
FTPS="" # remote ftp server
FTPF="/" # remote ftp server directory for $FTPU & $FTPP

wget -O $LOCALD

ncftpput -m -u $FTPU -p $FTPP $FTPS $FTPF $LOCALD

Thanks to Google and charvi

Doing the same for OpenWrt on nslu2

I was not able to find an opkg for ncftpput but yafc was available ("yet another ftp client")
this small script let me log on to my main server and upload a file called


wget -O /www/ramdisk/home_ip.html

echo "uploading to sunspot"
yafc <<**
open ftp://name:password@my.ftp.server/
cd /
put -f -r /www/ramdisk/home_ip.html


(It took some searching to find a way of scripting this - you could run yafc but then you ended up with a yafc prompt and no way to enter the put upload line.
The <<** seems to be the magic but it is not documented in the yafc man pages)

/etc/cron/root contains

# upload the IP address to sunspot every 20 minutes
*/20 * * * * /path-to/

(if using "crontab -e" you are in vi (!) - to save do esc :wq to save the changes)

This python program runs in minipython on the openwrt slug when called by the bash script (above)
which wgets the current IP address from and stores all of that webpage in the ramdisk. forms a string starting at character 76 of the html from the saved web page

the string.find makes x equal to the number along the string where the character < is found
This finds the end of the IP address which may be shorter than 4 quads of numbers

openfile = open('/www/ramdisk/home_ip.html', 'r')
string =

x = string.find ( '<' )
dottedquad = string[0:x]

f = open('/www/ramdisk/IP-address.txt', 'w')






also see

Comments? email me