Skip to content

Instantly share code, notes, and snippets.

@oskar456
oskar456 / README.md
Last active October 13, 2024 08:45
CLAT for Linux using Jool and ipvlan PoC

CLAT for Linux using ipvlan

This proof of concept uses ipvlan feature of Linux to split up main network interface into two in order to use one in a separate namespace with jool-siit performing CLAT translation.

This way, enabling CLAT is least intrusive to the default network namespace - no need to enable forwarding or touch firewall rules.

#!/usr/bin/env python3
import urllib.request
from collections import defaultdict
DELEGSTATS = "https://ftp.ripe.net/ripe/stats/delegated-ripencc-extended-latest"
def main():
"""
@oskar456
oskar456 / analyze_v6_only_preferred.py
Created July 15, 2022 12:14
Analyze IPv6-only preferred (option 108) in DHCP requests
#!/usr/bin/env python3
"""
Analyze a PCAP file containing DHCP Discover messages.
Print stats including number of unique MAC addresses,
number of MAC addresses requesting DHCP option 108
(IPv6-only Preferred) and MAC adresses flapping between
requesting and not requesting it.
To collect PCAP file, tcpdump can be used like this:
@oskar456
oskar456 / pref64.diff
Created July 5, 2022 11:42
A quick and dirty patch to add Pref64 RA option to odhcpd (RFC 8781)
diff --git a/src/router.c b/src/router.c
index 541c023..9ad79d4 100644
--- a/src/router.c
+++ b/src/router.c
@@ -390,6 +390,7 @@ enum {
IOV_RA_ROUTES,
IOV_RA_DNS,
IOV_RA_SEARCH,
+ IOV_RA_PREF64,
IOV_RA_ADV_INTERVAL,
@oskar456
oskar456 / a-poor-mans-hypervisor-scripts.md
Last active February 7, 2022 14:15
Poor man's VM hypervisor scripts

A poor man's hypervisor scripts

These scripts are written mostly in bash in order to spawn a bunch of similar KVM VMs, have each have its own SSH key for the root account (which can be e-mailed to people) and be able to destroy all the machines easily once the work is done.

There is unfortunatelly no documentation whatsover.

@oskar456
oskar456 / gaitest.c
Last active May 24, 2021 11:09
Test getaddrinfo NAT64 synthesis on macOS
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <err.h>
int main(int argc, char *argv[]) {
@oskar456
oskar456 / atlas_claimer.sh
Last active March 4, 2021 08:45
Claim 1,000,000 RIPE Atlas credits every time you can
#!/bin/bash
# Dependencies: curl, jq, realpath, date (GNU), at
API_KEY="FIXME"
claim_endpoint() {
local regid=$1
curl -s -H "Content-Type: application/json" \
-H "Accept: application/json" \
@oskar456
oskar456 / data.yaml
Last active October 18, 2020 19:46
Ansible bug with datetime in data
---
data_1:
- id: 1
key: hello
- id: 2
key: world
data_2:
- id: 1
@oskar456
oskar456 / wgwatchdog.sh
Last active February 27, 2023 03:44
Wireguard tunnel watchdog for OpenWRT
#!/bin/sh
check_reachability() {
local target="$1"
local retval
ping6 -c1 -W1 "$target" >/dev/null 2>&1
retval="$?"
[ "$retval" -eq 2 ] && {
ping -c1 -W1 "$target" >/dev/null 2>&1
retval="$?"
@oskar456
oskar456 / oneshot_setup.sh
Created July 5, 2020 17:23
Raspberry Pi Zero USB gadget mode with ethernet and serial
#!/bin/sh
# Enable gadget mode
echo "dtoverlay=dwc2,dr_mode=peripheral" >> /boot/config.txt
systemctl enable setupgadget.service
# alternatively: ln -s /etc/systemd/system/setupgadget.service /etc/systemd/system/basic.target.wants/setupgadget.service
# Enable getty on the virtual serial line
systemctl enable [email protected]
# alternatively: ln -s /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]