Skip to content

Instantly share code, notes, and snippets.

oskar456 /
Last active May 21, 2024 01:34
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
def main():
oskar456 /
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 / 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 {
oskar456 /
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 / 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 /
Last active March 4, 2021 08:45
Claim 1,000,000 RIPE Atlas credits every time you can
# Dependencies: curl, jq, realpath, date (GNU), at
claim_endpoint() {
local regid=$1
curl -s -H "Content-Type: application/json" \
-H "Accept: application/json" \
oskar456 / data.yaml
Last active October 18, 2020 19:46
Ansible bug with datetime in data
- id: 1
key: hello
- id: 2
key: world
- id: 1
oskar456 /
Last active February 27, 2023 03:44
Wireguard tunnel watchdog for OpenWRT
check_reachability() {
local target="$1"
local retval
ping6 -c1 -W1 "$target" >/dev/null 2>&1
[ "$retval" -eq 2 ] && {
ping -c1 -W1 "$target" >/dev/null 2>&1
oskar456 /
Created July 5, 2020 17:23
Raspberry Pi Zero USB gadget mode with ethernet and serial
# 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/
# Enable getty on the virtual serial line
systemctl enable serial-getty@ttyGS0.service
# alternatively: ln -s /lib/systemd/system/serial-getty@.service /etc/systemd/system/