Skip to content

Instantly share code, notes, and snippets.

@daegalus
Last active December 14, 2015 12:08
Show Gist options
  • Save daegalus/5084535 to your computer and use it in GitHub Desktop.
Save daegalus/5084535 to your computer and use it in GitHub Desktop.
Raspberry Pi Pong script. On boot, updates a central server with its current WAN and LAN ip so it can be booted headlessly on any network.
import urllib2
import commands
lanip = commands.getoutput('netstat -n -t | awk \'{print $4}\' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1" | sort -u')
wanip = urllib2.urlopen('http://ipv4.icanhazip.com').read().strip()
result = urllib2.urlopen('http://yulian.kuncheff.com/rpi/?ip='+lanip+'&lanip='+wanip,"").read()
if result != 'Ok':
sys.stderr.write('There was an errror posting IPs : '+result+'\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment