| Another solution is to use an MMDB (“MaxMind DB”) file [1] which is essentially a binary tree + deduplicated values (same as idea 3.1). There are several free ASN MMDBs [2,3] but you can also build your own MMDB files from any Prefix->Value mapping with the mmdbwriter library [4] or a CLI tool built on top of it like mmdbctl [5]. Assuming the ASN MMDB is fully loaded in memory, it would use around 60MB. [1] https://maxmind.github.io/MaxMind-DB/ [2] https://dev.maxmind.com/geoip/docs/databases/asn/ [3] https://ipinfo.io/products/free-ip-data-downloads [4] https://github.com/maxmind/mmdbwriter [5] https://github.com/ipinfo/mmdbctl (I work for IPinfo, but there are lots of other companies offering MMDB files). |
[1] https://cloud-ips.s3-us-west-2.amazonaws.com/index.html