Skip to content

Instantly share code, notes, and snippets.

@kerus1024
Created April 26, 2020 10:07
Show Gist options
  • Save kerus1024/575da48e019d68bd1f43a60625d6ce83 to your computer and use it in GitHub Desktop.
Save kerus1024/575da48e019d68bd1f43a60625d6ce83 to your computer and use it in GitHub Desktop.
Bash IP Resolve
#!/bin/bash
#
# RHEL: bind-utils
# Debian based : bind9-host
#
WATCH_DOMAIN="1dot1dot1dot1.cloudflare-dns.com"
EXEC_VAR=`host -4 -t A $WATCH_DOMAIN | head -n 1 | awk '{print $4}'`
if ! [[ $EXEC_VAR =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Fail Lookup!"
exit 1
fi
echo "Success Lookup!: $EXEC_VAR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment