ASN/IPv4/IPv6/Prefix/ASPath lookup tool.
The script will perform an AS path trace (using mtr in raw mode and retrieving AS data from the results) for single IPs or DNS results (screenshots below).
The script uses Team Cymru's whois service for data.
Generic usage
Example ASPath trace to www.github.com
To download the asn script from your shell:
curl https://raw.githubusercontent.com/nitefood/asn/master/asn > asn && chmod +x asn
After that, you can use the script by running ./asn.
asn <ASnumber>-- to lookup matching ASN data. Supports "as123" and "123" formats (case insensitive)asn <IPv4/IPv6>-- to lookup matching route(4/6) and ASN dataasn <ROUTE>-- to lookup matching ASN dataasn <host.name.tld>-- to lookup matching IP(v4/v6), route and ASN data (supports multiple IPs - e.g. DNS RR)
AS path tracing is enabled by default for lookup results involving a single IP address. This can be disabled by passing the [n|--notrace] command line switch.
This script was featured in the Security Trails blog post "ASN Lookup Tools, Strategies and Techniques". Thank you Esteban!
Any feedback or pull request to improve the code is welcome. Feel free to contribute!