Get IP ranges for domain

dig +short yandex.ru | xargs -L 1 whois -h whois.radb.net | grep 'origin:' | sed 's/origin:\s\+/!g/' | uniq | xargs -L 1 whois -h whois.radb.net | tr -s ' ' '\012' | tail -n +2 | head -n -1 | sort | uniq

where:

  • dig +short yandex.ru - retrieve ip addresses for domain
  • whois -h whois.radb.net - retrieve whois info for ip address

inside whois info there is "origin: AS13238" where origin is kind of id

whois -h whois.radb.net '!gAS13238' - retrieve registered ip blocks

bash, nslookup, whois, dig