1
General Discussion / Updated Python script to whois BGP ASNs and get a list of network blocks.
« on: January 02, 2020, 11:46:48 pm »
It's probably not a very common use case, but I need the ability to make policy routing decisions to destination networks owned by specific organizations. On pfS I was using pfBNG to resolve BGP Autonomous System numbers to network blocks, as this isn't a core feature for pFs either.
There are some old threads here and here discussing it, and the base code contributed by NilsS that I built off of can be found there.
What I've done since then is made it work with Python 3, but also made it a bit easier to use and added a method to call it via http. This means you can self-host the script, and feed/update OPNsense aliases automatically.
Personally, I run it as a Docker container, but there's no requirement to use Docker. All you need is python with Flask ("pip install Flask", if you don't have it already). There are some public services that can do this as well, but I prefer to run my own just in case I accidentally run into API limits or the service unexpectedly disappears.
I readily admit that I can barely code my way out of a paper bag. I feel like what I did with Flask is clunky as hell, but it works. PRs welcome.
https://github.com/ddimick/asn-to-ip
https://hub.docker.com/r/ddimick/asn-to-ip
There are some old threads here and here discussing it, and the base code contributed by NilsS that I built off of can be found there.
What I've done since then is made it work with Python 3, but also made it a bit easier to use and added a method to call it via http. This means you can self-host the script, and feed/update OPNsense aliases automatically.
Personally, I run it as a Docker container, but there's no requirement to use Docker. All you need is python with Flask ("pip install Flask", if you don't have it already). There are some public services that can do this as well, but I prefer to run my own just in case I accidentally run into API limits or the service unexpectedly disappears.
I readily admit that I can barely code my way out of a paper bag. I feel like what I did with Flask is clunky as hell, but it works. PRs welcome.
https://github.com/ddimick/asn-to-ip
https://hub.docker.com/r/ddimick/asn-to-ip