From dd4c49d7f1b4b4112a21595528c77987b00f59fd Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Tue, 27 Mar 2018 03:55:58 +0000 Subject: Fallback to external DNS --- phonehome.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phonehome.sh b/phonehome.sh index f469d6c..3aa7cef 100755 --- a/phonehome.sh +++ b/phonehome.sh @@ -13,13 +13,15 @@ KEY=/root/.ssh/phonehome.id_rsa CRONTAB=/var/spool/cron/crontabs/root CRON_ENTRY="*/5 * * * * /root/phonehome.sh" +DEFAULT_HOST="phonehome.crute.me" + # Alt host hedges against DNS being down if the default DNS server is on the # wrong side of a collapsed ssh tunnel # # Grab only answers starting with numbers since we're trying to resolve the IP # itself not the hostname (in the absence of normal DNS). Grab the first numeric # answer in the case of multiple records -HOST_IP=$(dig +short @8.8.8.8 phonehome.crute.me | awk '/^[0-9]+/ { print $0; exit; }') +ALT_HOST=$(dig +short @8.8.8.8 phonehome.crute.me | awk '/^[0-9]+/ { print $0; exit; }') function start_autossh { autossh -f \ @@ -48,5 +50,5 @@ else fi if ! pgrep autossh > /dev/null; then - start_autossh $HOST_IP + start_autossh $ALT_HOST fi -- cgit v1.2.3