Skip to content

Instantly share code, notes, and snippets.

@Edison-Hsu
Created April 9, 2018 08:17
Show Gist options
  • Save Edison-Hsu/a5664fc5bf4e111db5c7c746e324f304 to your computer and use it in GitHub Desktop.
Save Edison-Hsu/a5664fc5bf4e111db5c7c746e324f304 to your computer and use it in GitHub Desktop.

Revisions

  1. Edison-Hsu created this gist Apr 9, 2018.
    15 changes: 15 additions & 0 deletions check_domain.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #! /bin/sh

    DOMAIN="us0.0bad.com"
    IP=`dig +short $DOMAIN`
    OLD_IP=`cat ip.txt`

    if [ "$OLD_IP" = "$IP" ]; then
    echo "query $DOMAIN address: $IP" >> query_ip.log
    else
    echo "query $DOMAIN address changed, old: $OLD_IP, new: $IP" >> query_ip.log
    echo $IP > ip.txt
    sh ip_forward.sh $IP
    fi;

    echo "$(tail -10 query_ip.log)" > query_ip.log