Kernel-based WireGuard extension for wg-punch library
  • Go 98.2%
  • Makefile 1.8%
Find a file
2026-05-03 20:47:57 +02:00
.github Fix github action not running 2026-05-03 20:45:32 +02:00
cmd feat(kernel): lint code, add doc and remove unused main 2025-05-25 01:15:39 +02:00
kernel feat(kernel): lint code, add doc and remove unused main 2025-05-25 01:15:39 +02:00
.gitignore feat: add README, Makefile, linter 2025-04-26 14:56:05 +02:00
.golangci.yml feat: add README, Makefile, linter 2025-04-26 14:56:05 +02:00
go.mod Bump dependencies to latest version 2026-05-03 20:47:57 +02:00
go.sum Bump dependencies to latest version 2026-05-03 20:47:57 +02:00
LICENSE add README and LICENSE 2025-05-25 01:22:47 +02:00
Makefile feat: add README, Makefile, linter 2025-04-26 14:56:05 +02:00
README.md add README and LICENSE 2025-05-25 01:22:47 +02:00

wg-punch-kernel: WireGuard Punch Kernel Extension

wg-punch-kernel extends wg-punch to support kernel-based WireGuard tunnels for NAT hole punching in Go.

Overview

This module provides a Tunnel implementation that uses the WireGuard kernel module instead of the userspace version. It is a drop-in replacement for wg-punchs userspace tunnel, using the kernel WireGuard module for native integration with the system networking stack.

  • Reuses wg-punchs NAT traversal logic
  • Uses kernel WireGuard for real tunnel setup
  • Cleanly integrates with your existing Go code
  • Tested with peer-to-peer TCP communication over WireGuard

Use Case

Use this project when:

  • You want to establish direct peer-to-peer connections across NATs using WireGuard
  • You prefer kernel WireGuard (via wgctrl and netlink) over userspace wireguard-go
  • You already use or plan to use wg-punch

Example

See cmd/peerA/main.go and cmd/peerB/main.go for a minimal example of establishing a tunnel between two peers using NAT hole punching and kernel WireGuard.

Requirements

  • Linux with WireGuard kernel module installed
  • Go 1.20+

Installation

go get github.com/yago-123/wg-punch-kernel