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 / Juniper-Trio-IPv4-IP-Options-punted.md
Created November 6, 2026 13:50
Transit IPv4 packets with IP options header field punted to control-plane || Juniper's KB30719 || related to CVE-2026-98432 || discussion on Packet Pushers Slack group
@tonusoo
tonusoo / irrd.yaml
Last active November 5, 2026 12:18
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