aboutsummaryrefslogtreecommitdiff
path: root/README
blob: cd58d79b06d0c543d39259c32085e18386fa5a19 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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"
  }