-
-
Save starkers/5951e4cf91baf04c98a2 to your computer and use it in GitHub Desktop.
Determine you're outbound (http) IP and reverse DNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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