Created
February 22, 2018 13:45
-
-
Save techdad/9cbfefb9341ba295dc0d22051f35de5a to your computer and use it in GitHub Desktop.
Get the origin ASN(s) for the name-server set for a domain using dig and the Cymru Origin-AS WHOIS service.
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 | |
if [[ -z $1 ]]; then | |
echo "Usage: $0 {domain}" | |
exit 1 | |
fi | |
DOMAIN="$1" | |
SERVER="whois.cymru.com" | |
PORT="43" | |
exec 3<>/dev/tcp/${SERVER}/${PORT} | |
echo "begin" >&3 | |
dig +nssearch $DOMAIN |awk '{print $11}' >&3 | |
echo "end" >&3 | |
echo >&3 | |
while read -t 2 line; do | |
echo $line | |
done <&3 | |
exec 3<&- | |
exec 3>&- | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment