Created
May 18, 2020 15:14
-
-
Save 330k/5d11fe91f76f5f13ef35795c161491d3 to your computer and use it in GitHub Desktop.
どんなときもWi-Fi通信監視用 グローバルIP変化監視スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IP_OLD="" | |
while true | |
do | |
IP=`curl -m 3 -s http://inet-ip.info` | |
if [[ ${IP} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
if [[ "$IP" != "$IP_OLD" ]]; then | |
IP_OLD="$IP" | |
echo `date '+%Y/%m/%d %H:%M:%S'`" $IP "`dig -x $IP +noall +answer | grep PTR | rev | cut -f1 | rev` | |
fi | |
else | |
if [[ "$IP" != "" ]]; then | |
IP_OLD="" | |
echo `date '+%Y/%m/%d %H:%M:%S'`" Connection Error" | |
fi | |
fi | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment