I run a lot of standalone raspberry pi. Often for very small installations. So I have a standard image for all new rasp pis. On startup it will send its own IP address to a fixed server. So after starting one I have a quick look at the server, which is the current IP to access it over ssh in case. This is my script sending the IP address to the server.

# get own ip
IP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
# send data
URL="http://myserver.com?parameter=one"
/usr/bin/curl --data-urlencode "parameter=$IP" $URL > /dev/null 2>&1

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.