![None](/media/filer_public_thumbnails/filer_public/2f/90/2f90200f-7203-4e6f-909c-53812fb7b196/ip-address.jpg__1600x900_q85_crop_subsampling-2_upscale.jpg)
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" username@company.com fi echo "`date +%Y-%m-%d\ %T` $OUTSIDE_IP" >> /root/last_ip.log
- Posted by Kostas Koutsogiannopoulos · Nov. 24, 2015