November 16, 2021
WireGuard aims for improved performance over earlier VPN protocols. After several years in development, it became stable enough for its first production release in March 2020.
The WireGuard project provides a graphical user interface (GUI) client for WireGuard on Windows. However, it does not officially support WireGuard as a server on Windows. It is assumed that your server will run Linux.
Henry Chang has documented a hack that allows you to run WireGuard as a server on a Windows PC. This post fleshes out the details of the method. The WireGuard server can be an ordinary home PC running Windows. It does not need to run the Windows Server edition of Windows.
Bear in mind the disclaimer on Henry Chang’s post: “Using WireGuard on Windows as server is not officially supported. Use at your own risk.”
This section covers the steps you need to perform on the computer that will act as your WireGuard server. It is assumed that this computer is on a local area network (LAN) behind a home router.
Open a Windows Command Prompt by holding down the Win key and pressing r, then typing cmd
and pressing Enter.
Issue the command:
ipconfig
Identify your LAN address in the response. It will fall into one of the ranges 10.0.0.0
through 10.255.255.255
, 172.16.0.0
through 172.31.255.255
, or 192.168.0.0
through 192.168.255.255
.
Make a note of your PC’s IPv4 address on the LAN. You’ll need to know it for the next step.
Close the Command Prompt window.
While you can change the port WireGuard uses, in this post we’ll assume you’re using the default, UDP port 51820
.
You need to do two things on your router:
51820
51820
from the outside world (the wide-area network or WAN) to your PC on the LAN
The procedures for opening a router firewall and configuring port forwarding vary from router to router, so detailed instructions cannot be given here. Consult the documentation for your particular make and model of router.
You do not want your computer to be asleep when you try to connect from the outside world. Therefore configure its power plan to prevent the PC from ever going to sleep.
You probably don’t have a static IP address at home. In this step, you’ll subscribe to a Dynamic DNS service. This will give your Window machine a fixed DNS host name, even if its IP address changes from time to time.
bob7878.hopto.org
)
We are using UDP port 51820
in this example. You have already opened that port in your router and port forwarded it to your PC. Now open that port on your PC:
firewall
51820
, and click NextWireGuard Inbound
, and click FinishIn this step, you’ll install WireGuard on your PC then close the GUI window that opened automatically at the end of the install.
wireguard-installer.exe
Not tested: https://lists.zx2c4.com/pipermail/wireguard/2021-August/006887.html announced a new “kernel” version of WireGuard for Windows named WireGuardNT. To enable it, insert a new registry DWORD HKLM > Software > WireGuard > ExperimentalKernelDriver
with value 1
.
bob7878.hopto.org:51820
in our example)Scroll down the page. You will see configuration files for your server and client. For example, for the server:
[Interface] Address = 10.0.0.1/24 ListenPort = 51820 PrivateKey = CPEwyMFrjozEtq94SeoIoZv+eg7bntlOSGSfZRSb+WY= [Peer] PublicKey = rfIHzbGTVisJm0NIISuKl62TGgBEpyj4AF4bzeu5bAs= AllowedIPs = 10.0.0.2/32
And for the client:
[Interface] Address = 10.0.0.2/24 ListenPort = 51820 PrivateKey = KKxM64CbXyciGHIOUF03a+QAraZZDPU+EYcztN7i1Fc= [Peer] PublicKey = 5+ZEsuLX+XwPHw3xSzGh8hn4zdBt0zED+dAXRq8pjiU= AllowedIPs = 0.0.0.0/0, ::/0 Endpoint = bob7878.hopto.org:51820
Save the generated WireGuard configurations:
C:
driveC:\wireguard
C:\wireguard\wg_server.conf
(with no .txt
on the end)C:\wireguard\wg_client.conf
(with no .txt
on the end)Open a Windows Command Prompt as administrator by typing cmd
in the Windows search box and selecting Run as administator.
Issue this command (it is one long command, even though it may appear to span multiple lines on narrow screens):
"C:\Program Files\WireGuard\wireguard.exe" /installtunnelservice "C:\wireguard\wg_server.conf"
This creates a service called WireGuardTunnel: wg_server
, which can be controlled using standard Windows service management utilites.
Close the Command Prompt window.
Windows assigns a category to each network you connect to:
0
Public — an untrusted network (e.g. public Wi-Fi) where you want the firewall to block most input from other devices1
Private — a trusted network (e.g. home or office) where you trust the other devices on the network2
Domain — a network where the computers are all members of an Active Directory domainOptionally set the WireGuard’s network category to Private in order to give clients easy access to networked resources:
Get-NetConnectionProfile
InterfaceIndex
of your new WireGuard server connectionSet-NetConnectionProfile -InterfaceIndex 10 -NetworkCategory Private
The WireGuard interface does not yet have access to your physical interface. This will severely limit what clients can do. Enable sharing of the main physical interface as described in this step.
Save the following PowerShell script module as C:\Windows\System32\WindowsPowerShell\v1.0\Modules\wireguard\wireguard.psm1
:
wireguard.psm1
Now open PowerShell running as administrator, and run the following commands to enable NAT for your WireGuard interface:
Set-ExecutionPolicy Unrestricted Import-Module wireguard Set-NetConnectionSharing "wg_server" $true
Check the settings in the GUI:
regedit
in the Windows search boxHKEY_LOCAL_MACHINE
> SYSTEM
> CurrentControlSet
> Services
> SharedAccess
> Parameters
ScopeAddress
to 10.0.0.1
ScopeAddressBackup
to 10.0.0.1
service
in the Windows search boxregedit
in the Windows search boxHKEY_LOCAL_MACHINE
> SOFTWARE
> Microsoft
> Windows
> CurrentVersion
> SharedAccess
EnableRebootPersistConnection
1
Restart the Windows computer that will be your WireGuard server.
Wait for the delayed start service (Internet Connection Sharing) to start running.
This section shows you the steps to perform on the computer that will travel with you — for example, your Windows laptop.
wireguard-installer.exe
C:\wireguard\wg_client.conf
from your server to your clientwg_client.conf
file on the client, click Add Tunnel > Import tunnel(s) from filewg_client.conf
file, and import it into the WireGuard client GUIA reminder that using WireGuard on Windows as server is not officially supported. Keep in mind that requests for support are likely to be rejected: