Skip to content

Commit 20a3b03

Browse files
authored
Merge pull request #42 from zmap/phillip/routing-improvements
Fix regression introduced with Routing module and add MRT download instructions
2 parents b6be97f + 14207e4 commit 20a3b03

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

README.md

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

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

6182
## Output

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/oschwald/geoip2-golang v1.13.0
88
github.com/osrg/gobgp/v3 v3.37.0
99
github.com/sirupsen/logrus v1.9.3
10-
github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837
10+
github.com/zmap/go-iptree v0.0.0-20251001212402-0a55a77d6804
1111
github.com/zmap/zdns/v2 v2.0.5
1212
gotest.tools/v3 v3.5.2
1313
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ github.com/zmap/go-dns-root-anchors v0.0.0-20250415191259-6d65fb878756 h1:yeprVD
7070
github.com/zmap/go-dns-root-anchors v0.0.0-20250415191259-6d65fb878756/go.mod h1:W5CEzaf+B3Pg1hzUQotwQ2EBg7jB49DkmKuiNuWPO80=
7171
github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 h1:DjHnADS2r2zynZ3WkCFAQ+PNYngMSNceRROi0pO6c3M=
7272
github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837/go.mod h1:9vp0bxqozzQwcjBwenEXfKVq8+mYbwHkQ1NF9Ap0DMw=
73+
github.com/zmap/go-iptree v0.0.0-20251001212402-0a55a77d6804 h1:jcY3/CdJnd4A5bO3m5ebZyV533Owz8A6NlDoWE/WQgQ=
74+
github.com/zmap/go-iptree v0.0.0-20251001212402-0a55a77d6804/go.mod h1:9vp0bxqozzQwcjBwenEXfKVq8+mYbwHkQ1NF9Ap0DMw=
7375
github.com/zmap/zcrypto v0.0.0-20250416162916-8ff8dfaa718d h1:QcrqQ8a285ozWrRrsPUtYl4y+9YJAM4gSTF3EQDTQk8=
7476
github.com/zmap/zcrypto v0.0.0-20250416162916-8ff8dfaa718d/go.mod h1:Zz4/7kyRgJXC+PTpLV4tIgaCMTHWnNbgOLZoXuVrkws=
7577
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)