Skip to content

Instantly share code, notes, and snippets.

@dfrankland
Last active August 29, 2015 14:21
Show Gist options
  • Save dfrankland/e81184266f529373413d to your computer and use it in GitHub Desktop.
Save dfrankland/e81184266f529373413d to your computer and use it in GitHub Desktop.
Check for changes in WAN ip using http://ifconfig.me
#!/bin/bash
ip1="";
ip2="";
changed=0;
date1=$( date "+%s" )
while true; do
ip1=$(curl -s ifconfig.me/ip);
if [[ "$ip1" != "$ip2" ]]; then
changed=$(( changed + 1 ));
date2=$( date "+%s" )
diff=$(( date2 - date1 ))
echo "Changed IP: $ip1 | Changed Total: $changed | Time Change: $(( diff / 60 )) min. $(( diff % 60 )) sec. | Time: $( date "+%c" )";
ip2=$ip1;
date1=$date2
fi
done;
@dfrankland
Copy link
Author

Easy way to run this:

bash <(curl -s https://gist.githubusercontent.com/dukedylan/e81184266f529373413d/raw/81584e81bda28d4407e81e3f7ffb334bf168123c/check-if-ip-changed.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment