Skip to content

Instantly share code, notes, and snippets.

View tonusoo's full-sized avatar

Martin Tonusoo tonusoo

  • Tallinn, Estonia
View GitHub Profile
@tonusoo
tonusoo / irrd.yaml
Last active October 23, 2026 09:47
Local Internet Routing Registry (IRR) server setup for route filtering || tested on IRRd version 4.5.3 || NANOG mailing list thread: https://lists.nanog.org/archives/list/nanog@lists.nanog.org/thread/QYURU4X3Y5H3F7EAX3EEGEX4YOTOVZ63/
irrd:
# For performance reasons, use an Unix domain socket
# for communicating with both the PostgreSQL (socket
# is /run/postgresql/.s.PGSQL.5432) and Redis.
# For PostgreSQL only the peer authentication is
# allowed.
database_url: 'postgresql:///irrd'
redis_url: 'unix:///run/redis/redis-server.sock'
# In Filesystem Hierarchy Standard 3.0, /var/run
@tonusoo
tonusoo / RFC7908_3-4_route-leak.md
Created October 20, 2026 09:02
verifying the entire AS path against the customer cone on an upstream router || RFC 7908 || NANOG mailing list thread: https://lists.nanog.org/archives/list/nanog@lists.nanog.org/thread/O5XX6BHOSMINX4HKT2SMVOI66SMYXFOR/
@tonusoo
tonusoo / dump-irr-db.py
Last active October 8, 2026 09:05
Dumps IRRd database IRR route objects to JSON file || NANOG mailing list thread: https://lists.nanog.org/archives/list/nanog@lists.nanog.org/thread/O5XX6BHOSMINX4HKT2SMVOI66SMYXFOR/
#!/usr/bin/env python3
"""
Fetches valid route and route6 objects from the IRRd PostgreSQL
database and atomically generates a JSON file formatted for RTRTR.
Expected to be run by systemd-timer under the 'irrd' user.
"""
import ipaddress
import json
@tonusoo
tonusoo / per-country-aspa-objects-simplistic.py
Last active July 27, 2026 09:17
RPKI ASPA objects for AS numbers registered in a country || discussion on CERT-EE channel
#!/usr/bin/env python3
"""RPKI ASPA objects for ASes registered in a country.
Script finds all the AS numbers from RIR statistics files
for a country in which the AS number holder is legally based.
AS numbers are checked against the RPKI ASPA dataset and ASNs
are categorized into two groups: ones with an ASPA object and
ones without it.
@tonusoo
tonusoo / per-country-aspa-objects.py
Last active July 26, 2026 15:01
RPKI ASPA objects for AS numbers associated with a country || discussion on CERT-EE channel
#!/usr/bin/env python3
"""RPKI ASPA objects for ASes associated with a country.
Script finds all the v4 and v6 address ranges geolocated to a user-
specified country. For each address range possible exact and more-
specific prefixes from DFZ are found. If the exact prefix was not
found and more-specifics do not fully cover the geolocated address
range, then also less-specific prefixes are checked. Finally, all
the unique origin ASNs for the found prefixes are checked against
@tonusoo
tonusoo / per-country-roa-analysis.py
Last active July 3, 2026 18:56
RPKI ROA analysis of BGP prefixes covering EE address space || discussion on CERT-EE channel
#!/usr/bin/env python3
"""RPKI ROA analysis of BGP prefixes covering country's address space.
Script finds all the v4 or v6 address ranges geolocated to a user-
specified country. For each address range possible exact and more-
specific prefixes from DFZ are found. If the exact prefix was not
found and more-specifics do not cover the geolocated address range,
then also less-specific prefixes are checked. Finally, all the unique
prefix and ASN tuples from DFZ are checked against the RPKI ROA dataset.
@tonusoo
tonusoo / RFC7908_lateral_ISP-ISP-ISP_leak_via_RS.md
Created May 18, 2026 10:38
verifying the entire AS path against the customer cone on a route server || RFC 7908 || NANOG mailing list thread: https://lists.nanog.org/archives/list/nanog@lists.nanog.org/thread/W7OMPSYMCHFR5N7VZFX2Y4JR7D4AU4ID/
@tonusoo
tonusoo / napt-44.conf
Created April 28, 2026 15:22
Port Address Translation with MS-DPC || j-nsp mailing list thread: https://puck.nether.net/pipermail/juniper-nsp/2026-April/039361.html
root@lab-mx960> show configuration services
service-set pat-service-set {
nat-rules rule-napt-44;
interface-service {
/* first PIC of MS-DPC in slot 9; Multiservices MIC should use "ms" interface instead of "sp" interface */
service-interface sp-9/0/0;
}
}
nat {
pool napt-pool {
@tonusoo
tonusoo / aspa_logic.py
Last active April 14, 2026 11:44
A validation script for the "ASPA-based AS Path Verification Examples" document referenced in https://datatracker.ietf.org/doc/draft-ietf-sidrops-aspa-verification/ based on https://github.com/QratorLabs/ASPA
#!/usr/bin/env python3
# https://github.com/QratorLabs/ASPA
# https://github.com/ksriram25/IETF/blob/main/ASPA_path_verification_examples.pdf
import sys
import logging
DEBUG_MODE = True
@tonusoo
tonusoo / ROA-ASPA-openssl.txt
Created March 30, 2026 14:21
Extracting and decoding the ASN.1 DER payloads of RPKI CMS signed objects using OpenSSL
martin@validator-2:~$ # routinator dump --output /tmp/routinator-dump/
martin@validator-2:~$ # "<- ..." comments below are manually added
martin@validator-2:~$ openssl cms -verify -noverify -inform DER -in /tmp/routinator-dump/store/rrdp.arin.net/rpki.arin.net/repository/arin-rpki-ta/5e4a23ea-e80a-403e-b08c-2171da2157d3/69fd0156-bb1f-48b6-bf32-c9492286f195/de4a1dfa-8867-4aef-a2e6-131e93add9f9/5486ade0-fc94-3e8d-89dc-e03fab376ea9.roa -outform DER | openssl asn1parse -inform DER -i -dump
CMS Verification successful
0:d=0 hl=2 l= 28 cons: SEQUENCE
2:d=1 hl=2 l= 3 prim: INTEGER :02571B <- ASN 153371 (RFC 6482 ASID)
7:d=1 hl=2 l= 21 cons: SEQUENCE
9:d=2 hl=2 l= 19 cons: SEQUENCE
11:d=3 hl=2 l= 2 prim: OCTET STRING
0000 - 00 02 .. <- v6 addr family (RFC 6482 addressFamily)