Skip to content

Instantly share code, notes, and snippets.

@330k
Created May 18, 2020 15:14
Show Gist options
  • Save 330k/5d11fe91f76f5f13ef35795c161491d3 to your computer and use it in GitHub Desktop.
Save 330k/5d11fe91f76f5f13ef35795c161491d3 to your computer and use it in GitHub Desktop.
どんなときもWi-Fi通信監視用 グローバルIP変化監視スクリプト
#!/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