-
Notifications
You must be signed in to change notification settings - Fork 53
getip
Ulrich Berntien edited this page Mar 22, 2019
·
2 revisions
getip - get external IP from akamai and google (HTTP and DNS)
getip
getip uses two methods to retrieve the external IP address of the box:
- "whatismyip.akamai.com" over HTTPS. For the HTTPS download either curl, wget, perl or python is used.
- query one of Googles nameservers that returns your external IP. For the query dig or host is used.
Google and Akamai were chosen as they are less suspect than, say, ifconfig.co or whatever in any upstream logs.
getip() {
#we use akamai and google here because they're gonna look less dodgy in SOC's lolgs
echo "Attempting to get IP..."
echo -ne "HTTP says: "
orc_loadURL 'https://whatismyip.akamai.com'
echo ""
echo -ne "DNS says: "
if hash dig>/dev/null; then
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | tr -d \"
echo -ne "(used dig)\n"
else
host -t txt o-o.myaddr.l.google.com ns1.google.com | grep descriptive | awk -F ' ' '{print $4}' | tr -d '"' | tr -d "\n"
echo -ne "(used host)\n"
fi
}