ipranges
List of IP ranges extracted from the BGP Routing Information Base (RIB) downloaded from RIPE.
Example
package main
import (
"fmt"
"code.forgejo.org/forgejo/ipranges"
)
func main() {
i := ipranges.New()
_ = i.Load()
for _, iprange := range i.Get() {
fmt.Println(iprange)
}
}
Description
This list of IP ranges was first compiled when
code.forgejo.org attempted to mitigate a DDoS. It is meant to be used to find the IP ranges that contributed most to a DDoS and block them to keep it contained. A mitigation feature was described for Forgejo and half implemented but then abandonned because it is out of scope.
The Regional Internet Registries (RIRs) (as advertised by whois) is an alternative source but some RIR do not make it available to the general publicly. The Routing Information Base (RIB) (used by BGP) contains a subset of those IP ranges (not all of them are routed).
The list is updated weekly. Statistics collected in 2024 show that there is approximately a 5% change in the list of IP ranges every week.
Hacking
The release.yml workflow can be manually triggered for debugging purposes.
When rebuilding an existing release, the most time consuming part (downloading the BGP dumps and parsing them) is skipped.
export TMPDIR=/tmp/testipranges
mkdir $TMPDIR
./generate.sh main
Parse just one RRC:
./generate.sh get_rrc_ipranges 19
Use just one RRC:
echo 19 > $TMPDIR/rrc
Use a BGP dump from 2024-12-10:
TODAY=2024-12-10 ./generate.sh main
Measure the size of the data:
go test -c
objdump -s -j .noptrdata iprange.test | less
Search for something like 01000000 18 if an ipranges.go line is:
{1,0,0,0,24},
For instance:
55a1c0 01000000 01000000 01000000 18000000 ................
55a1d0 01000400 16000000 01001000 18000000 ................
55a1e0 01004000 12000000 01008000 11000000 ..@.............
It is expected that the table is padded and instead of 5 bytes there
actually are 8 used.