asn: map hosts to their corresponding ASN via HTTP/WHOIS usage: asn.py [-h] [--whois-host WHOIS_HOST] [--whois-port WHOIS_PORT] [--http-host HTTP_HOST] [--http-port HTTP_PORT] [--update] [--populate] options: -h, --help show this help message and exit --whois-host WHOIS_HOST IP to listen on for WHOIS service (default: 127.0.0.1) --whois-port WHOIS_PORT Port to listen on for WHOIS service (default: 4343) --http-host HTTP_HOST IP to listen on for HTTP service (default: 127.0.0.1) --http-port HTTP_PORT Port to listen on for HTTP service (default: 8080) --update Update dataset submodule and create/populate cache (default: False) --populate Create and populate cache from current dataset (default: False) INSTALL $ git submodule init $ git submodule update --recursive --remote $ doas apk add py3-gitpython py3-waitress py3-flask (Alpine) $ ./asn.py --populate $ ./asn.py optional: forward traffic destined for port 43 (WHOIS default) back to 4343 $ iptables -A PREROUTING -t nat -p tcp --dport 43 -j REDIRECT --to-ports 4343 USAGE $ whois -h 127.0.0.1 1.1.1.1 IP Address | AS Number | Country | AS Name | Announcement -----------+-----------+---------+---------------+------------- 1.1.1.1 | 13335 | AU | CLOUDFLARENET | 1.1.1.0/24 $ whois -h 127.0.0.1 jordan.im IP Address | AS Number | Country | AS Name | Announcement ------------------+-----------+---------+-------------------+--------------- 185.73.44.145 | 8943 | GB | Jump Networks Ltd | 185.73.44.0/22 2001:ba8:0:4031:: | 8943 | GB | Jump Networks Ltd | 2001:ba8::/32 $ curl 127.0.0.1:8080 { "host": "8.8.8.8", "hostname": "dns.google", "org": "AS15169 GOOGLE", "announcement": "8.8.8.0/24" }