This Gist is a companion for the Creating a Linux 'yogurt-phone' — with netkit and a grain of eBPF blog post. It demoes Linux' netkit interface pairs with a local netns-to-netns communication scenario, inspired by "Yogurt Phones". Netkit interfaces are successors for veth tailor made for eBPF and high performance.
Create a 'lab' setup:
#!/bin/bash
set -euo pipefail
for i in {1..2}
do
NETNS="yogurt-${i}"
IFNAME_PREFIX="yg${i}"
echo "➡️ Creating netns ${NETNS}..."
# Reset the network namespace
mountpoint -q "/run/netns/${NETNS}" && sudo ip netns del "${NETNS}"
sudo ip netns add "${NETNS}"
# Create and setup the interface pair with both sides in blackhole mode
sudo ip link add "${IFNAME_PREFIX}-host" type netkit blackhole peer blackhole name "${IFNAME_PREFIX}-cont"
sudo ip link set "${IFNAME_PREFIX}-cont" netns "${NETNS}"
sudo ip netns exec "${NETNS}" ip addr add "10.42.0.${i}/24" dev "${IFNAME_PREFIX}-cont"
sudo ip netns exec "${NETNS}" ip link set lo up
sudo ip netns exec "${NETNS}" ip link set "${IFNAME_PREFIX}-cont" up
sudo ip link set "${IFNAME_PREFIX}-host" up
done
echo "All done ✅"
exit 0Build and run:
go mod init hello-netkit
go mod tidy
go get github.com/cilium/ebpf/cmd/bpf2go
go generate && go build && sudo ./hello-netkitThe setup can be tested with a simple ping 10.42.0.2 in the first netns, with the program running, and without:
sudo ip netns exec yogurt-1 ping 10.42.0.2
See https://blog.yadutaf.fr/2025/09/16/creating-a-yogurt-phone-with-netkit-ebpf/ for the full blog post.