wireguard-go README

The project's README from github.com/WireGuard/wireguard-go. As one markdown file: README.md.

Go Implementation of WireGuard

This is an implementation of WireGuard in Go.

Usage

Most Linux kernel WireGuard users are used to adding an interface with ip link add wg0 type wireguard. With wireguard-go, instead simply run:

$ wireguard-go wg0

This will create an interface and fork into the background. To remove the interface, use the usual ip link del wg0, or if your system does not support removing interfaces directly, you may instead remove the control socket via rm -f /var/run/wireguard/wg0.sock, which will result in wireguard-go shutting down.

To run wireguard-go without forking to the background, pass -f or --foreground:

$ wireguard-go -f wg0

When an interface is running, you may use wg(8) to configure it, as well as the usual ip(8) and ifconfig(8) commands.

To run with more logging you may set the environment variable LOG_LEVEL=debug.

Platforms

Linux

This will run on Linux; however you should instead use the kernel module, which is faster and better integrated into the OS. See the installation page for instructions.

macOS

This runs on macOS using the utun driver. It does not yet support sticky sockets, and won't support fwmarks because of Darwin limitations. Since the utun driver cannot have arbitrary interface names, you must either use utun[0-9]+ for an explicit interface name or utun to have the kernel select one for you. If you choose utun as the interface name, and the environment variable WG_TUN_NAME_FILE is defined, then the actual name of the interface chosen by the kernel is written to the file specified by that variable.

Windows

This runs on Windows, but you should instead use it from the more fully featured Windows app, which uses this as a module.

FreeBSD

This will run on FreeBSD. It does not yet support sticky sockets. Fwmark is mapped to SO_USER_COOKIE.

OpenBSD

This will run on OpenBSD. It does not yet support sticky sockets. Fwmark is mapped to SO_RTABLE. Since the tun driver cannot have arbitrary interface names, you must either use tun[0-9]+ for an explicit interface name or tun to have the program select one for you. If you choose tun as the interface name, and the environment variable WG_TUN_NAME_FILE is defined, then the actual name of the interface chosen by the kernel is written to the file specified by that variable.

Building

This requires an installation of the latest version of Go.

$ git clone https://git.zx2c4.com/wireguard-go
$ cd wireguard-go
$ make

License

Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

wireguard-go (WireGuard/wireguard-go)

Searching Database…

What is this?wireguard-go is a userspace implementation of the WireGuard VPN written in Go: it runs as a normal program that creates a WireGuard network interface, instead of living inside the OS kernel.
So is this a VPN app I install, or something lower-level?It is lower-level: there is no GUI here. Running it creates an interface like wg0 and forks to the background, and you configure that interface with the standard wg(8), ip(8) and ifconfig(8) tools.
How do I bring up a WireGuard interface with it?Run 'wireguard-go wg0' — it creates the interface and forks into the background (pass -f or --foreground to stay in the foreground). Remove it later with 'ip link del wg0', or by deleting the control socket /var/run/wireguard/wg0.sock, which shuts it down.
What do I need to build it?Just the latest version of Go — that is the only build prerequisite the README states.
Are there OS-specific gotchas I should know about?Yes. The macOS port uses the utun driver, lacks sticky sockets and fwmark support, and only allows interface names like utun0 or utun1; the FreeBSD and OpenBSD ports also lack sticky sockets (fwmark is mapped to SO_USERCOOKIE / SO_RTABLE), and OpenBSD restricts names to tun[0-9]+.
When would I choose this userspace version over regular WireGuard?Where the kernel module is not an option — macOS and the BSDs — or when you want WireGuard embedded in your own software: the official Windows app is built on wireguard-go as a module. On Linux and Windows the README steers everyday users to other packages.
Which operating systems does it run on?Linux, macOS, Windows, FreeBSD and OpenBSD are all covered — though the README says Linux users should prefer the faster, better-integrated kernel module, and Windows users are pointed to the full WireGuard app that embeds this code.
How do I get more verbose logs when a tunnel misbehaves?Set the environment variable LOGLEVEL=debug before launching wireguard-go — that is the built-in switch for more detailed logging.
Is this GitHub repository the official one?No — it is a mirror only. The official repository lives at https://git.zx2c4.com/wireguard-go.
Creator
WireGuard
Size
1.8 MB
Stars
4.5K
Updated
CommitOct 06
Age
8y
Commits · 90 Days