Last active
March 11, 2019 03:34
-
-
Save jmacego/9d125249d3fa825c99379a09d97eaa28 to your computer and use it in GitHub Desktop.
Query Level3s IRR for prefixes advertised by an AS MACRO, in blocks short enough to not break Kibana's URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function # Python 2 compatibility fix | |
from sys import argv, exit | |
from subprocess import check_output | |
# Takes AS MACRO as single argument | |
prefixes = check_output(['whois -h filtergen.level3.net \ | |
"ARIN::{} -searchpath=RIPE;ARIN;RADB \ | |
-recurseok -warnonly"'.format(argv[1])], shell=True) | |
i = 0 | |
for line in prefixes: | |
print('ip_dst: "{}" OR ip_src: "{}" '.format(line, line), end="") | |
i += 1 | |
if i > 19: | |
i = 0 | |
print("\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment