Skip to content

Instantly share code, notes, and snippets.

@finnigja
Created November 8, 2022 23:58
Show Gist options
  • Save finnigja/a021319f05215e82e812b78e6c31edbe to your computer and use it in GitHub Desktop.
Save finnigja/a021319f05215e82e812b78e6c31edbe to your computer and use it in GitHub Desktop.
# got a list of IPs you need to do lookups for?
# map them back to their ASes with Team Cymru's DNS-based IP-to-ASN lookup service...
$ for asn in $(
for ip in $(cat ips.txt); do
revip=$(echo $ip | awk -F. '{print $4"."$3"."$2"."$1}');
dig +short $revip.origin.asn.cymru.com TXT;
done | cut -d ' ' -f 1 | cut -c 2- | sort | uniq
);
do dig +short AS$asn.asn.cymru.com TXT;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment