Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dynamic DNS
- By using a domain name service, you can easily connect to your Raspberry Pi when you are not home. This is actually necessary if the IP address given by your provider changes frequently. But also if you always have the same IP: simply using a pretty url to connect is nice.
- Schedule this script to run every x hours, mine runs every 4 hours:
- crontab -e
- add this line at the bottom:
- 0 */4 * * * sudo sh /etc/ipupdate/ipupdate.sh
- # this script will check if the current external IP address has been changed by your ISP internet provider.
- # If so, it will update your subdomain (for example: mypc.freedns.org). This way, you will always be able to
- # connect to your Raspberry when you are not at home and don't know the IP address of your home. Also handy
- # if your ISP internet provider keeps changing your IP.
- TOKEN="UHpTbTVsZGtIODBuWldKY0IxcW1hWTlBOjEwNDg1NDY2"
- IFACE=eth0
- if test -f /etc/ipupdate/ipupdate.conf
- then
- CacheIP=$(cat /etc/ipupdate/ipupdate.conf)
- fi
- ExternIP=$(wget -qO- http://ipecho.net/plain)
- if [ "$ExternIP" = "$CacheIP" ]
- then
- # Both IP are equal
- echo "Update not required..."
- else
- # The IP has change
- echo "Updating http://free.afraid.org with " $ExternIP
- wget http://freedns.afraid.org/dynamic/update.php?$TOKEN -o /dev/null -O /dev/stdout
- echo `date` "Updating log with IP " $ExternIP >> /var/log/dmesg
- fi
- sudo rm -f /etc/ipupdate/ipupdate.conf
- sudo echo $ExternIP > /etc/ipupdate/ipupdate.conf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement