Introduction and Motivation

I started using wireguard some five years ago. Touted as simple and user-friendly, I quickly realized its learning curve was steeper than expected. The labyrinth of networking concepts and system tools seemed like voodoo magic to me. This experience was one of many that steered me towards Rust, a language that promised more clarity in the often murky waters of low-level system networking and programming. While I’ve grown comfortable with Rust as a system programming language, yet the domain itself remained somewhat mystical. For example, the inner workings of wireguard seemed like a well-kept secret, leaving me wondering how it managed to create an alternative Internet and the roles of those iptables incatations in its PostUp. My curiosity was reignited when I stumbled upon Jon Gjengset (jonhoo)’s Implementing TCP in Rust stream. His discussion about the tun interface was an eye-opener. Despite years as a web engineer and countless encounters with wg0, I was oblivious to this concept. Jonhoo’s explanation was a revelation, and suddenly, the pieces began to fall into place.

Motivated by this newfound understanding, I decided to dive deeper into lower-level network programming through a practical approach: creating a simplified version of wireguard, focusing on packet routing and bypassing the complexities of security and VPN protocols. Though the project was small, the journey was packed with enlightening moments and intriguing detours. This led to my decision to document the process, naming the project wontun.