Skip to content

Instantly share code, notes, and snippets.

@rohan-molloy
Last active May 30, 2019 15:08
Show Gist options
  • Save rohan-molloy/4e3f0fc8b189c3155a093eb5edfece9e to your computer and use it in GitHub Desktop.
Save rohan-molloy/4e3f0fc8b189c3155a093eb5edfece9e to your computer and use it in GitHub Desktop.
One Liner To Get ISP announced prefix

One Liner To Get ISP announced prefix info

dig +short `curl --silent ipecho.net/plain | awk -F. '{print $4"."$3"." $2"."$1}'`.origin.asn.cymru.com TXT

Example

rohan@vm01:~$ dig +short `curl --silent ipecho.net/plain | awk -F. '{print $4"."$3"." $2"."$1}'`.origin.asn.cymru.com TXT
"46652 | 67.205.128.0/20 | US | arin | 2016-04-12"
rohan@vm01:~$

Extracting out the raw prefix

Here we simply use AWK

dig +short `curl --silent ipecho.net/plain | awk -F. '{print $4"."$3"." $2"."$1}'`.origin.asn.cymru.com TXT | awk '{print $3}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment