Skip to content

Commit b8d7c9b

Browse files
Merge branch 'phillip/31-ipinfo-enrichment' of github.com:zmap/zannotate into phillip/31-ipinfo-enrichment
2 parents c8aa31d + 0ef055a commit b8d7c9b

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ echo "1.1.1.1" | zannotate --geoasn --geoasn-database=/path-to-downloaded-file/G
5757
{"ip":"1.1.1.1","geoasn":{"asn":13335,"org":"CLOUDFLARENET"}}
5858
```
5959

60+
### BGP Routing Tables
61+
1. Go to [https://archive.routeviews.org/route-views2/bgpdata/](https://archive.routeviews.org/route-views2/bgpdata/)
62+
2. Select a month directory (e.g. `2025.09`)
63+
3. Select the `RIBS/` directory
64+
4. Download a BZiped MRT file (e.g. `rib.20250923.1200.bz2`)
65+
5. Unzip the file with:
66+
67+
```shell
68+
bzip2 -d ./path-to-downloaded-file/rib.20250923.1200.bz2
69+
```
70+
71+
6. Test with:
72+
73+
```shell
74+
echo "1.1.1.1" | ./zannotate --routing --routing-mrt-file=/tmp/rib.20250923.1200
75+
```
76+
77+
```json
78+
{"ip":"1.1.1.1","routing":{"prefix":"1.1.1.0/24","asn":13335,"path":[3561,209,3356,13335]}}
79+
```
80+
6081
# Input/Output
6182

6283
## Output

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ require (
88
github.com/oschwald/maxminddb-golang/v2 v2.0.0-beta.10
99
github.com/osrg/gobgp/v3 v3.37.0
1010
github.com/sirupsen/logrus v1.9.3
11-
github.com/zmap/dns v1.1.67
12-
github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837
11+
github.com/zmap/dns v1.1.67
12+
github.com/zmap/go-iptree v0.0.0-20251001212402-0a55a77d6804
1313
github.com/zmap/zdns/v2 v2.0.5
1414
gotest.tools/v3 v3.5.2
1515
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ github.com/zmap/go-dns-root-anchors v0.0.0-20250415191259-6d65fb878756 h1:yeprVD
7272
github.com/zmap/go-dns-root-anchors v0.0.0-20250415191259-6d65fb878756/go.mod h1:W5CEzaf+B3Pg1hzUQotwQ2EBg7jB49DkmKuiNuWPO80=
7373
github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 h1:DjHnADS2r2zynZ3WkCFAQ+PNYngMSNceRROi0pO6c3M=
7474
github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837/go.mod h1:9vp0bxqozzQwcjBwenEXfKVq8+mYbwHkQ1NF9Ap0DMw=
75+
github.com/zmap/go-iptree v0.0.0-20251001212402-0a55a77d6804 h1:jcY3/CdJnd4A5bO3m5ebZyV533Owz8A6NlDoWE/WQgQ=
76+
github.com/zmap/go-iptree v0.0.0-20251001212402-0a55a77d6804/go.mod h1:9vp0bxqozzQwcjBwenEXfKVq8+mYbwHkQ1NF9Ap0DMw=
7577
github.com/zmap/zcrypto v0.0.0-20250416162916-8ff8dfaa718d h1:QcrqQ8a285ozWrRrsPUtYl4y+9YJAM4gSTF3EQDTQk8=
7678
github.com/zmap/zcrypto v0.0.0-20250416162916-8ff8dfaa718d/go.mod h1:Zz4/7kyRgJXC+PTpLV4tIgaCMTHWnNbgOLZoXuVrkws=
7779
github.com/zmap/zdns/v2 v2.0.5 h1:RNrKZWki/LzKIXiHcO3oJwVM0mXkwu5mNs5s3Phniy0=

zrouting/routinglookup.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ func (t *RoutingLookupTree) PopulateFromMRTFiltered(raw io.Reader, pathFilter Pa
9292
if len(n.Path) > 0 {
9393
n.ASN = n.Path[len(n.Path)-1]
9494
}
95-
err := t.IPTree.AddByString(e.Prefix, n)
95+
// Set the node in the tree
96+
err := t.IPTree.SetByString(e.Prefix, n)
9697
if err != nil {
9798
return fmt.Errorf("could not add prefix %s to IP tree: %w", e.Prefix, err)
9899
}

0 commit comments

Comments
 (0)