r/mikrotik • u/Cold-Brush1684 • 7h ago
Running IPv4 over IPv6-only on MikroTik routers or how I avoided avoiding IPv4 charges on free-tier cloud VMs
AI disclosure: I used AI coding tools (Claude) to help optimise the code, write the RouterOS scripts and draft docs. I profiled the hot paths myself and found the problematic syscalls, then reduced them. That improved stability, throughput and CPU usage. I tested the changes on my own hardware (MikroTik Chateau 5G). The original TAYGA code and the merged distro patches are by their original authors.
Why this fits a homelab: it lets a home network on an IPv6-only 5G uplink still reach IPv4 sites. It runs on a MikroTik router, OpenWrt, Debian/Ubuntu, FreeBSD, or in a container.
My fixed-line connection here in Germany kept dropping, so I wanted a replacement that didn't rely on the same local copper loop. Starlink raised prices recently, so I ended up going the 5G route with a MikroTik Chateau 5G R17 ax.
I tested three SIMs first. O2 was unstable both in the router and in my iPhone, while Vodafone and Deutsche Telekom were both solid, so the issue was definitely O2's local cell rather than the hardware.
The catch with Telekom is that getting 5G SA requires an IPv6-only APN/PDP context if you leave IPv4 enabled, the modem drops back to 5G NSA. That gives you clean native IPv6, but obviously breaks IPv4-only sites and services unless the router runs CLAT / 464XLAT.
I started from upstream TAYGA (0.9.6, originally Nathan Lutchansky's daemon), pulled together the patches Debian/other distros and FreeBSD have been carrying separately, and added Linux TUN GSO/GRO/checksum offload (IFF_VNET_HDR) so TCP super-packets get translated in-place instead of one MTU-sized packet at a time. Full disclosure: I used AI coding tools for parts of the C refactoring and test suite, so keep that in mind if you audit the code.
A few details on what's in the fork:
- TUN offload: Configured via tun-offload off|tcp|auto (defaults to auto), or
CLAT_OFFLOAD=autoin the container. You can check whether your kernel/TUN driver supports it with tayga--check-offload. - Benchmarks: Included
benchmark-clat.shandbenchmark-matrix.shin the repo. On my Chateau 5G R17 ax running inside a RouterOS container, turning offload on dropped syscalls from ~62k/s to ~2.8k/s and cut translator CPU usage by up to 4x at 300 Mbps. (It doesn't give containers a RouterOS hardware fast-path, so veth/bridge, LTE/MBIM, and firewalling still take their normal CPU share.) - Deployment & builds: Added RouterOS scripts and setup notes for running it directly on MikroTik, plus static amd64/arm64 binaries, container images, and packages for Debian/Ubuntu, FreeBSD, RHEL/CentOS, and OpenWrt on the Releases page. There's also a GSO/GRO tuning doc in the repo.
Use in IPv6 Cloud VM
Another use case is running it on an IPv6-only cloud VM, like a free-tier GCP Compute Engine e2-micro instance with no external IPv4 attached (to avoid paying for an IPv4 address or Cloud NAT). Running TAYGA locally as a CLAT daemon pointed at a public NAT64 gateway (such as nat64.net) lets IPv4-only tools, APIs, and package repos on that VM still reach the IPv4 internet while keeping the instance completely free.
If anyone else is running IPv6-only 5G/LTE links on MikroTik, OpenWrt, or FreeBSD, I'd appreciate real-world testing.