blob: 160d1c3d96c1ec79d7c843a0b748c4c5d82c2b89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
asn: map hosts to their corresponding ASN via WHOIS
usage: asn.py [-h] [--host HOST] [--port PORT] [--update] [--populate]
optional arguments:
-h, --help show this help message and exit
--host HOST IP address to listen on
--port PORT Port to listen on
--update Update dataset submodule and create/populate cache
--populate Create and populate cache from current dataset
INSTALL
$ git submodule init
$ git submodule update --recursive --remote
$ doas apk add py3-gitpython (Alpine)
$ ./asn.py --populate
$ ./asn.py --host 0.0.0.0 --port 4343
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 whois.jordan.im 1.1.1.1
AS Number | Country | AS Name | Announcement
----------+---------+---------------+-------------
13335 | AU | CLOUDFLARENET | 1.1.1.0/24
$ whois -h whois.jordan.im jordan.im
AS Number | Country | AS Name | Announcement
----------+---------+-------------------+---------------
8943 | GB | Jump Networks Ltd | 185.73.44.0/22
8943 | GB | Jump Networks Ltd | 2001:ba8::/32
|