To determine if an Autonomous System (AS) uses Resource Public Key Infrastructure (RPKI) validation, you can query the RPKI validation state of a BGP Prefix by using the IRR REST API provided by RADB (https://www.radb.net/rpki/irr_api_doc).
Here's an example Python code using Requests library to query the API:
main.py211 chars8 linesIn this code, the check_rpki_validation function takes in two parameters - the Autonomous System number (asn) and the BGP Prefix (prefix). The function constructs the API URL by formatting the asn and prefix parameters into the URL string. The API returns a JSON response and the function extracts the validated field from the response data.
The validated field will have a boolean value - True if the BGP Prefix is validated by RPKI or False if it's not validated by RPKI.
You can call this function with the AS number and BGP prefix you want to query:
main.py52 chars2 lines
This will output True or False indicating if the BGP Prefix is validated by RPKI.
gistlibby LogSnag