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 / packet_capture_in_g-bird1.txt
Created September 17, 2025 08:47
Junos Non-Stop Active Routing and Fault-Tolerant TCP/IP test setup; https://cseweb.ucsd.edu/~marzullo/pubs/fttcp2.pdf
root@bird1:~# # acknowledgements to the client(10.10.10.1) are withheld until the hot backup has received the corresponding data
root@bird1:~# tshark -c 4 -i enp7s0 -f 'tcp and port 179'
Running as user "root" and group "root". This could be dangerous.
Capturing on 'enp7s0'
1 0.000000000 10.10.10.1 → 10.10.10.0 BGP 85 KEEPALIVE Message
2 0.601193559 10.10.10.0 → 10.10.10.1 TCP 66 179 → 60153 [ACK] Seq=1 Ack=20 Win=16384 Len=0 TSval=2273170037 TSecr=1268402651
3 4.135022182 10.10.10.0 → 10.10.10.1 BGP 85 KEEPALIVE Message
4 4.135067259 10.10.10.1 → 10.10.10.0 TCP 66 60153 → 179 [ACK] Seq=20 Ack=20 Win=126 Len=0 TSval=1268406786 TSecr=2273173570
4 packets captured
root@bird1:~#
#!/usr/bin/env bash
# Configures Juniper router to inject a 0x0b control character to
# "Shutdown Communication" field(RFC 9003) of a BGP cease NOTIFICATION message.
#
# Usage example:
# ./shutdown-bgp-session.bash | ssh [email protected] -p 830 -s netconf
vertical_tab=$'\v'
@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/[email protected]
[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";