Skip to content

Instantly share code, notes, and snippets.

@coderholic
Created September 30, 2020 00:03
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderholic/6942cb1daeb66d0c9fc90b4fd32fb09c to your computer and use it in GitHub Desktop.
Save coderholic/6942cb1daeb66d0c9fc90b4fd32fb09c to your computer and use it in GitHub Desktop.
Bulk hostname resolution with the IPinfo.io bulk endpoint
#!/bin/bash
sed 's/$/\/hostname/' | parallel --jobs=12 --pipe -N1000 \
"curl -s -XPOST -H 'Content-Type: text/plain' --data-binary @- 'ipinfo.io/batch?token=$TOKEN&filter=1'" | \
grep '"' | sed 's|/hostname||' | cut -d'"' -f2,4 | tr '"' '\t'
Copy link

ghost commented Sep 30, 2020

Hostname should be changed target.com . Right?

@coderholic
Copy link
Author

Nope, nothing needs changing (hostname selects the hostname field). You invoke like:

echo "8.8.8.8" | ipinfo_resolv.sh

Copy link

ghost commented Oct 1, 2020

Thanks For your reply!
I am confused , between the script and the host command, which tells you exactly the same thing.
What am I missing ?

@coderholic
Copy link
Author

Yeah it does give you exactly the same output as host. The difference is speed. If you want to lookup 1 IP (or maybe even 10) host is fine. By using the https://ipinfo.io API to do this you can lookup a whole /14 (262,144 IPs) in under 30 seconds. With host that'd take over an hour. See https://twitter.com/coderholic/status/1311098613334831107 for context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment