Skip to content

Instantly share code, notes, and snippets.

@starkers
Created May 17, 2014 16:57
Show Gist options
  • Save starkers/5951e4cf91baf04c98a2 to your computer and use it in GitHub Desktop.
Save starkers/5951e4cf91baf04c98a2 to your computer and use it in GitHub Desktop.
Determine you're outbound (http) IP and reverse DNS
#!/usr/bin/env bash
# Depends on curl and dig
TIMEOUT=1
SERVER=4.2.2.3
IP=`curl -s --connect-timeout "$TIMEOUT" https://outboundip.com 2>/dev/null`
#echo :$?:
if [ ! X$IP == "X" ]; then
PI=`dig -x $IP @$SERVER +short`
if [ ! "X$PI" == "X" ]; then
echo "IP=$IP; PTR=$PI"
else
echo "IP=$IP"
fi
else
echo "null"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment