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 / route.patch
Last active August 8, 2025 12:50
disables fallback to less specific routes explained in RFC 4191 3.2 and 3.6; patch --ignore-whitespace net/ipv6/route.c route.patch; tested on Linux 6.12.38
--- net/ipv6/route.c~ 2025-08-08 13:44:04.928000000 +0300
+++ net/ipv6/route.c 2025-08-08 13:48:01.448000000 +0300
@@ -2221,24 +2221,13 @@
int fib6_table_lookup(struct net *net, struct fib6_table *table, int oif,
struct flowi6 *fl6, struct fib6_result *res, int strict)
{
- struct fib6_node *fn, *saved_fn;
+ struct fib6_node *fn;
fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
@tonusoo
tonusoo / fix.txt
Created July 28, 2025 16:53
"can't open '/boot/loader.rc': no such file or directory" error in vJunos-router
qemu-nbd --connect=/dev/nbd0 vJunos-router-23.2R1.15.qcow2
fdisk -l /dev/nbd0
mkdir -p /tmp/nbd0p2
mount -v /dev/nbd0p2 /tmp/nbd0p2
qemu-nbd --connect=/dev/nbd1 /tmp/nbd0p2/home/pfe/junos/junos-virtual-x86-64-23.2R1.15.qcow2
mkdir -p /tmp/nbd1p3
mount -t ufs -v -o ro,ufstype=44bsd /dev/nbd1p3 /tmp/nbd1p3
cp -v /tmp/nbd1p3/boot/loader.rc .
umount /tmp/nbd1p3
qemu-nbd --disconnect /dev/nbd1
@tonusoo
tonusoo / r2_conditional-announcement.patch
Created April 20, 2025 14:54
Juniper conditional BGP announcement PoC
[edit policy-options]
+ prefix-list DC1-aggregate {
+ 10.10.0.0/23;
+ }
[edit policy-options]
+ policy-statement ISP-B-out-v4 {
+ term conditional-announcement {
+ from {
+ prefix-list DC1-aggregate;
+ condition conditional-announcement;
#!/usr/bin/env bash
# Find IPv4 prefixes which have non-unique origin AS number, i.e. the rightmost AS number.
get_origin_asn() {
last_asn_elem="${1##* }"
case "$last_asn_elem" in
"{"*"}")
# It's an AS-set.
@tonusoo
tonusoo / bgp_full_feed_with_gobgpd.md
Created February 10, 2025 16:17
injecting MRT data into BIRD || discussion on Packet Pushers Slack group

BGP full feed in lab environment with gobgpd and BIRD

Prefixes are injected with patched gobgp. Systemd service template for gobgpd processes:

martin@bgp-feed:~$ cat /etc/systemd/system/gobgpd@.service
[Unit]
Description=GoBGP Routing Daemon - instance %i
After=network.target syslog.service
ConditionPathExists=/usr/local/etc/gobgpd-%i.conf
#!/usr/bin/env bash
# Title : systemd-networkd-confgen
# Last modified date : 8.02.2024
# Author : Martin Tonusoo
# Description : Script manages systemd-networkd conf files
# with "[IPv6Prefix]" and "[IPv6SendRA]" configuration
# sections in /run/systemd/network/10-br0.network.d/
# directory. "[IPv6Prefix]" configuration is built based
# on the content of the files in /run/prefix-capture/
@tonusoo
tonusoo / bgp_simple.patch
Created November 27, 2024 13:52
patch bgp-hackathon/bgpd-3/Solution-2-much-better/bgp_simple.pl bgp_simple.patch
--- bgp_simple.pl~ 2024-11-27 12:26:17.057483859 +0200
+++ bgp_simple.pl 2024-11-27 14:46:48.435675124 +0200
@@ -16,6 +16,8 @@
use Net::BGP;
use Net::BGP::Process;
+STDOUT->autoflush(1);
+
my $version = "v0.12";
my $version_date = "22-Jan-2011";
#!/usr/bin/python3 -u
"""
-> eth0: 192.168.17.36 -> 172.16.20.3 | protocol UDP | port 6000 | DATA |
<- eth1: 10.0.0.2 -> 10.0.0.1 | protocol UDP | port 6000 | DATA |
apt install --no-install-recommends python3-pcapy python3-scapy
"""
@tonusoo
tonusoo / bird.conf
Last active August 7, 2025 08:05
RTIX Route Servers configuration for lab usage with BIRD. Tested on BIRD version 2.15.1.
log syslog all;
debug protocols all;
router id 213.184.52.1;
define rtix_rs_asn = 207800;
# BGP ipv4/ipv6 channel option "secondary" requires
# routing table to be sorted.
ipv4 table master4 sorted;
interfaces {
lo0 {
unit 0 {
family inet {
filter {
input-list [ discard-ip-options discard-frags accept-single-hop-bfd-v4 accept-multi-hop-bfd-v4 accept-bgp-v4 accept-ospf2 accept-vrrpv3-v4 accept-established-v4 accept-common-services-v4 discard-all-v4 ];
}
}
family inet6 {
filter {