What is my IP?
Make you linux machine inform you if external IP address is changed.
Lets say that you have a linux machine in a location with non static IP address but you need to access it from outside.
The following script is a quick way to avoid using a dynamic dns service. You can schedule it in a cron job and it will sent you an e-mail with the new IP address if it is changed:
#!/bin/bash OUTSIDE_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) LAST_IP=$(cat /root/last_ip.txt) if [ "$OUTSIDE_IP" != "$LAST_IP" ] then echo "OUTSIDE_IP has changed" echo $OUTSIDE_IP > /root/last_ip.txt echo "$OUTSIDE_IP" | mail -s "IP address is changed" firstname.lastname@example.org fi echo "`date +%Y-%m-%d\ %T` $OUTSIDE_IP" >> /root/last_ip.log
- Posted by Kostas Koutsogiannopoulos · Nov. 24, 2015