Skip to content

Instantly share code, notes, and snippets.

@suvl
Created October 18, 2023 09:18
Show Gist options
  • Save suvl/db3f87852ae3b3eb16a647ebcfb7234d to your computer and use it in GitHub Desktop.
Save suvl/db3f87852ae3b3eb16a647ebcfb7234d to your computer and use it in GitHub Desktop.
Find AS2860 IP addresses
#!/bin/bash
set -o pipefail
set -o nounset
set -o errexit
set -o errtrace
set -o functrace
set -o xtrace
set -o verbose
# get all IPs for the AS2860
ips=$(whois -h whois.radb.net -- '-i origin AS2860' | grep --extended-regexp '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+' --only-matching)
# return all these IPs in a json array
echo $ips | jq --raw-input --slurp --raw-output 'split("\n") | map(select(. != "")) | split(" ") | map(select(. != "")) | map({ip: .})'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment