How to Setup Wireguard VPN Server On Windows (2024)

This tutorial goes through the process of setting up a Wireguard server on Windows. Most Wireguard tutorials on the internet only give you the choice of hosting a server in a Linux environment. However, it is very possible to setup a windows server.

After searching for a tutorial to no avail, I spent a couple days to figure out the best way to do it and how to automate the process. Ideally you would still want to run it in an Linux environment, but if you have a use case for a windows server like me, you would appreciate just how flexible Wireguard is!

Prerequisite

  • Latest Wireguard Windows Client installed (Download here from official site)
  • Setup firewall rules (just as you would for a Linux server setup: open and forward ports 51820, configure ddns etc)

Disclaimer
Using Wireguard on Windows as server is not officially supported. Use at your own risk.

Step 1: Prepare Wireguard Server and Client Config File

This step is the same as other Linux tutorials.
I've provided my own server side and client side configs below, adjust to your own use case.

#Server Config[Interface]PrivateKey = #Replace with server private key#ListenPort = 51820Address = 192.168.200.1/24[Peer]#Client 1PublicKey = #Replace with client public key#PresharedKey = #Replace with pre-shared key#AllowedIPs = 192.168.200.2/32
#Client Config[Interface]PrivateKey = #Replace with client private key#Address = 192.168.200.2/24DNS = 1.1.1.1, 8.8.8.8[Peer]PublicKey = #Replace with server public key#PresharedKey = #Replace with pre-shared key#AllowedIPs = 0.0.0.0/0Endpoint = #Replace with server domain name or ip address#:51820

After you prepared the server config files, place it in a folder somewhere permanent.
For this tutorial I will assume the server config file is placed at C:\wireguard\wg_server.conf

Step 2: Start up the server

Instead of using the GUI to start the server, we will start it using command options.
At the time of this tutorial the official GUI only allows one connection at a time. If we use it to run the server, the GUI will be occupied and we won't be able to make a new connection without dropping the server interface.
Running the server using command line options allows us the keep the GUI free for daily use.
If you don't mind the GUI being occupied, you can just start the server on the GUI and skip to Step 3.

Use the following code to start / stop the server. Without saying, adjust the file paths if they are different on your system.
You need to run these with administrative privilege!

#Start serverC:\Program Files\WireGuard\wireguard.exe /installtunnelservice "C:\wireguard\wg_server.conf"#Stop serverC:\Program Files\WireGuard\wireguard.exe /uninstalltunnelservice wg_server

You will only need to run the command once, wireguard's background service will remember the run state over reboots.
Once you start the server, wireguard will create a new network adapter as the same name as your server config file. Thus for our tutorial, the network adapter name would be "wg_server"
Check if the network adapter is successfully created.

How to Setup Wireguard VPN Server On Windows (1)

Step 2.1: (Optional) Setting adapter profile
Now we have the wireguard adpater setup, it is recommended to change it to "Private" profile", by defaults the adapter is added as "Public". Private profile will allow greater compatibility for the clients (say you want to use some remote desktop etc). Public profile may block these ports and services.

To Do this we run three simple powershell commands with admin privilege manually:

#Open powershell with admin privilege and run the following:$NetworkProfile = Get-NetConnectionProfile -InterfaceAlias "wg_server"$NetworkProfile.NetworkCategory = "Private"Set-NetConnectionProfile -InputObject $NetworkProfile

Step 3: Enable server routing

Now that server is running, the client should be able to handshake (given that you have the correct ports open and forwarded correctly).
However, you will notice the client won't be able to access either the internet or the LAN network.
This is because by default windows do not bridge or NAT the wireguard interface with your actual physical internet interface.
In Linux this is done by some PostUp/PostDown firewall commands, which we do not use here.
Instead, we use a powershell script to enable the NAT (or in Windows term "internet sharing") function:

Function Set-NetConnectionSharing{ Param ( [Parameter(Mandatory=$true)] [string] $LocalConnection, [Parameter(Mandatory=$true)] [bool] $Enabled ) Begin { $netShare = $null try { # Create a NetSharingManager object $netShare = New-Object -ComObject HNetCfg.HNetShare } catch { # Register the HNetCfg library (once) regsvr32 /s hnetcfg.dll # Create a NetSharingManager object $netShare = New-Object -ComObject HNetCfg.HNetShare } } Process {#Clear Existing Share $oldConnections = $netShare.EnumEveryConnection |? { $netShare.INetSharingConfigurationForINetConnection.Invoke($_).SharingEnabled -eq $true} foreach($oldShared in $oldConnections) { $oldConfig = $netShare.INetSharingConfigurationForINetConnection.Invoke($oldShared) $oldConfig.DisableSharing() } # Find connections $InternetConnection = Get-NetRoute | ? DestinationPrefix -eq '0.0.0.0/0' | Get-NetIPInterface | Where ConnectionState -eq 'Connected' $publicConnection = $netShare.EnumEveryConnection |? { $netShare.NetConnectionProps.Invoke($_).Name -eq $InternetConnection.InterfaceAlias } $privateConnection = $netShare.EnumEveryConnection |? { $netShare.NetConnectionProps.Invoke($_).Name -eq $LocalConnection } # Get sharing configuration $publicConfig = $netShare.INetSharingConfigurationForINetConnection.Invoke($publicConnection) $privateConfig = $netShare.INetSharingConfigurationForINetConnection.Invoke($privateConnection) if ($Enabled) { $publicConfig.EnableSharing(0) $privateConfig.EnableSharing(1) } else { $publicConfig.DisableSharing() $privateConfig.DisableSharing() } }}

Note: The shell script is originally created by igoravl, I made some modification to simplify the process and get rid of some errors for our wireguard server application.

This shell script is written as a custom function "Set-NetConnectionSharing" and needs to be loaded in powershell.
Save the script in the following location:

C:\Windows\System32\WindowsPowerShell\v1.0\Modules\wireguard\wireguard.psm1

💡

wireguard.psm1 needs to be in a folder named wireguard for the function to be loaded by powershell

Now you can open a powershell window with administrative privilege and run the following commands to enable / disable NAT for our wireguard server interface.

#"wg_server" is the wireguard adapter name, replace it if you have something different.#Enable NATSet-NetConnectionSharing "wg_server" $true#Disable NATSet-NetConnectionSharing "wg_server" $false

If everything goes well, when you open the properties panel of your main internet network adaptor (Ethernet 3 in my case) the following options should be ticked:

How to Setup Wireguard VPN Server On Windows (2)

Notice also the "Home networking connection" field should be populated with your wireguard interface name (picture shows Wireguar_Server but should be wg_server if you are following the tutorial).

Technically you can do this through the windows gui using the properties menu manually, but having this script will allow you to automate the server start/stop process as you will see later on in the tutorial.

Now everything should be working correctly, the client should be able to reach the internet and LAN network you allow it to.

Step 3.1: Change default Internet Connection Sharing IP

By default, when internet sharing (NAT) is enabled, Windows will change the IP address of the adapter to something else (to avoid conflicts). However, we already know what ip address we want to adapter to be (set in the [interface] block in our wireguard config), which is 192.168.200.1 in our case.
To modify the default IP Windows will switch to, we can simply change the setting in registry.
Open Registry Editor and go to the following path:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SharedAccess\Parameters

Then simply change ScopeAddress and StandaloneDHCPAddress to the IP address we desire (192.168.200.1 in our case).

How to Setup Wireguard VPN Server On Windows (3)

Disable and re-enable Internet connection sharing (NAT) using the powershell command in Step 3 to make sure this change takes place (you might need to restart computer).

Step 4: Enable persistent Internet Sharing on restart (updated 2/12/2020)

Since there is a windows bug that internet connection sharing will not auto start on reboot, we need to change a few settings to make sure internet sharing is started. The earlier tutorial used a scheduled task to accomplish this, but I've found a better way after reading the windows bug fix here.

Open the Service window and find "Internet Connection Sharing":

How to Setup Wireguard VPN Server On Windows (4)

Chang the startup type to "Automatic":

How to Setup Wireguard VPN Server On Windows (5)

After that's done, finally we add a registry:

Path: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\SharedAccessType: DWORD (32bit)Setting: EnableRebootPersistConnectionValue: 1
How to Setup Wireguard VPN Server On Windows (6)

Step 4.1 (optional) Bat files to easily start / stop server manually

For convenience I also made two bat files to run these commands so I don't have to open comman prompt or powershell everytime to start and stop the server.

Server start batch script: (save as "start.bat" and run with admin privilege)

@echo off"C:\Program Files\WireGuard\wireguard.exe" /installtunnelservice "C:\Henry-Scripts\Wireguard_Server.conf""%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" Set-NetConnectionSharing "Wireguard_Server" $true

Server stop batch script: (save as "stop.bat" and run with admin privilege)

@echo off"%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" Set-NetConnectionSharing "Wireguard_Server" $false"C:\Program Files\WireGuard\wireguard.exe" /uninstalltunnelservice Wireguard_Server

Final Remarks:

Compared to Linux, setting up a windows wireguard server can be tricky.
However, I have done most of the ground work for you (the powershell script to enable NAT).
Running the powershell script on startup with 3 minutes delay is not elegant, but it works.
There should be a way to run the task after the wireguard service is started and running, but I wasn't able to get it to work. If you know how to get it to work, please share it with me.

If you like my work, feel free to buy me a coffee:
How to Setup Wireguard VPN Server On Windows (2024)

FAQs

How to setup WireGuard server in Windows? ›

WireGuard Windows setup
  1. Download the current version for Windows: https://www.wireguard.com/install/ and install.
  2. Run C:\Program Files\WireGuard\wireguard.exe and add an empty tunnel (we will configure the server side): ...
  3. Add another empty tunnel (we will configure the client side): Add tunnel → Add empty tunnel.

Does Windows VPN support WireGuard? ›

WireGuard® is a fast, lightweight, and secure VPN protocol used by default in our official Windows app. We strongly recommend using our official app on your PC.

How do I create a tunnel in WireGuard Windows? ›

To configure a WireGuard Tunnel:
  1. Navigate to VPN > WireGuard > Tunnels.
  2. Click. ...
  3. Fill in the WireGuard Tunnel settings as described in WireGuard Package Settings.
  4. Click Save Tunnel.
  5. Add firewall rules on Firewall > Rules, WAN tab to allow UDP traffic to the port for this WireGuard tunnel (WireGuard and Rules / NAT)
May 1, 2023

How do I host a VPN server on Windows? ›

  1. Step 1: Update your Windows System. ...
  2. Step 2: Install Remote Access Role in Your Windows Server 2022. ...
  3. Step 3: Set Up Routing and Remote Access. ...
  4. Step 4: Configure the VPN Properties. ...
  5. Step 5: Configuring NAT Properties. ...
  6. Step 6: Restart Routing and Remote Access. ...
  7. Step 7: Configure Windows Firewall. ...
  8. Step 8: Create VPN User.
Feb 26, 2024

How to configure VPN server in Windows? ›

In Add a VPN connection, do the following:
  1. For VPN provider, choose Windows (built-in).
  2. In the Connection name box, enter a name you'll recognize (for example, My Personal VPN). ...
  3. In the Server name or address box, enter the address for the VPN server.
  4. For VPN type, choose the type of VPN connection you want to create.

How do I create a simple VPN server? ›

Create a VPN on Your Router
  1. Download custom firmware. Confirm compatibility between your router and preferred firmware, and then download it.
  2. Connect your computer to your router. Do this via a wired connection. ...
  3. Log into your router. ...
  4. Install the firmware. ...
  5. Reboot the router. ...
  6. Set up your VPN. ...
  7. Check if your VPN works.

How do I create a local VPN server? ›

How to Set up a VPN on Your Router
  1. Type your router's internet protocol (IP) address and password to log into your admin panel.
  2. Find the VPN option in the settings.
  3. Select the option for VPN client, not VPN server.
  4. Enter the correct settings. ...
  5. Complete any additional steps your router may request.
Jan 30, 2024

Which server is better OpenVPN or WireGuard? ›

The biggest notable differences between WireGuard and OpenVPN are speed and security. While WireGuard is generally faster, OpenVPN provides heavier security. The differences between these two protocols are also what make up their defining features.

How does WireGuard work on Windows? ›

You add a WireGuard interface, configure it with your private key and your peers' public keys, and then you send packets across it. All issues of key distribution and pushed configurations are out of scope of WireGuard; these are issues much better left for other layers, lest we end up with the bloat of IKE or OpenVPN.

Is WireGuard VPN free? ›

WireGuard is originally open source and can be used for free, absolutely.

What ports does WireGuard VPN server use? ›

By default, WireGuard uses UDP port 51820. L2TP (Layer Two Tunneling Protocol) - this one uses various port numbers as well; TCP port 1701, UDP port 4500, and UDP port 500.

Can you host WireGuard on Windows? ›

WireGuard VPN provider is one of the best free VPNs for Windows, macOS, Android, iOS, Linux kernel and BDS. Providing the users a speedy and easy interface with a strong level of encryption, one can now surf on the internet without the worry of being traced.

Does WireGuard tunnel all traffic? ›

1 Answer. Like most other VPN systems, Wireguard doesn't make any such decisions on its own – it will route exactly those prefixes that you've configured to be routed through the connection, which may be anywhere from "all traffic" (/0 route) to "a single IP address" (/32 route).

Is WireGuard a full tunnel? ›

WireGuard supports Full Tunnel VPN routing. This means that when the client connects, all Internet traffic routes over the tunnel. This is useful to ensure that the device is fully protected by all security layers of NG Firewall.

How do I run WireGuard on Windows without admin? ›

Fortunately there is a way to fix this. The Wireguard entry likely does not already exist under HKLM/Software (it's not there by default) so you can create it in Regedit. Under this key, create a new DWORD value called LimitedOperatorUI and set it to 1.

How do I run WireGuard as non administrator Windows? ›

Logout and login as the non-admin user. Find the WireGuard program, right-click and select "run as admin" one time. Then reboot and it should work for the non-admin user.

What is the difference between WireSock and WireGuard? ›

While WireGuard does not natively support server functionality on Windows, WireSock VPN Gateway bridges this gap. It circumvents the limitations and complexities associated with the standard Windows Internet Connection Sharing (ICS) when attempting to use WireGuard in a server role.

Top Articles
▷▷ 【 27 Ejemplos de Monografías IB cortas (hechas en Word y PDF) 】 ❤️
12 Best Free Movie & TV Show Streaming Sites in 2022
Stayton Craigslist
No Hard Feelings Showtimes Near Metropolitan Fiesta 5 Theatre
Behind the Screens: Understanding the Wisconsin Volleyball Team Leak
Shiftwizard Login Wakemed
Mashle: Magic And Muscles Gogoanime
Monkey Werx Sitrep 2022
When Does Dtlr Close
Chase Bank Pensacola Fl
Lynchburg Arrest.org
Which Statement About These Two Restaurant Meals Is Correct
Paperless Pay.talx/Nestle
Dtlr On 87Th Cottage Grove
Keanu Reeves cements his place in action genre with ‘John Wick: Chapter 4’
Stanford Rival Crossword Clue
Www.burlingtonfreepress.com Obituaries
Wicked Local Plymouth Police Log 2023
Craigslist Ludington Michigan
Budokai Z Pre Alpha Trello
Papa's Games Unblocked Games
Convert liters to quarts
Who are Yasmin Le Bon Parents? Meet Iradj Parvaneh and Patricia Parvaneh
Maryland Parole Hearing Schedule 2023
Theater X Orange Heights Florida
Gopher Hockey Forum
Mercedes E-Klasse Rembekrachtigers voorraad | Onderdelenlijn.nl
Black Adam Showtimes Near Linden Boulevard Multiplex Cinemas
Qmf Bcbs Prefix
Student Exploration Gravity Pitch
Magicseaweed Bob Hall
Craigslist Tampa: Your Ultimate Guide To Online Classifieds
Lookwhogotbusted New Braunfels
1084 Sadie Ridge Road, Clermont, FL 34715 - MLS# O6240905 - Coldwell Banker
Harleyxwest Of Leaks
Ontpress Fresh Updates
Closest Postal Service To My Location
Kurlyrose
Vuse Pod Serial Number Lookup
Grupos De Cp Telegram
Josh Bailey Lpsg
Dr Roger Rosenstock Delray Beach
Dc Networks Claimant Services
Alles, was ihr über Saison 03 von Call of Duty: Warzone 2.0 und Call of Duty: Modern Warfare II wissen müsst
Kristine Leahy Spouse
Daftpo
Ultipro Fleet Farm
Olive Onyx Amora
How To Spend a Day in Port Angeles (15 Things to Do!)
Live TV | Halifax | CBC Gem
Xochavella Leak
What stores are open on Labor Day 2024? A full list of where to shop
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 6144

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.