I want to get all IP address ranges/blocks from as number. I can search throw google but need to write them manually. I want to get them all at once? Is this possible to get only ip address ranges from websites at once?
Asked
Active
Viewed 2,239 times
3 Answers
3
If you don't have whois installed, you can achieve similar using a direct TCP connection to the WHOIS server.
For IPv4:
echo '-i origin AS15169' | nc whois.radb.net 43 | grep '^route:'
For IPv6:
echo '-i origin AS15169' | nc whois.radb.net 43 | grep '^route6:'
Similar can be achieved with Python using the socket
lib (in the standard library):
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(('whois.radb.net', 43))
s.sendall(b"-i origin AS15169\n")
result = ''
while True:
data = s.recv(16).decode('utf8')
if not data:
break
result += data
result = [i for i in result.split('\n') if i.startswith('route')]
print (result)

moo
- 1,597
- 1
- 14
- 29
2
You can use whois servers instead of bgp.he.net or any other websites like this.
whois -h whois.radb.net -- '-i origin AS01' | grep 'route:'
Just run this command on your Linux machine.

Sakib Mahmud
- 36
- 4
-
Is it possible to run in windows? – Percy Kiehn Mar 21 '21 at 07:25
-1
sh ip bgp regex _<number>$
this shows the advertised netbocks from AS known to the local machine (on a cisco, quagga or FRR router). Some looking glasses will let you make this search (some won't).

zBeeble
- 334
- 1
- 11