Wireguard Windows Server


### windows install service
```type"C:\Program Files\WireGuard\wireguard.exe" /installtunnelservice "C:\wireguard\wg_server.conf"```


### `C:\Windows\System32\WindowsPowerShell\v1.0\Modules\wireguard\wireguard.psm1`
```typeFunction 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()        }    }}```



### to private
```type$NetworkProfile = Get-NetConnectionProfile -InterfaceAlias "wg_server"$NetworkProfile.NetworkCategory = "Private"Set-NetConnectionProfile -InputObject $NetworkProfile ```
## reboot 하고나서
### admin
```typeSet-ExecutionPolicy RemoteSignedImport-Module wireguardSet-NetConnectionSharing "wg_server" $true```



```typeWindows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\SharedAccess]"EnableRebootPersistConnection"=string:1[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SharedAccess\Parameters]"ScopeAddress"=string:192.168.200.1[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SharedAccess\Parameters]"ScopeAddressBackup"=string:192.168.200.1[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SharedAccess\Parameters]"StandaloneDHCPAddress"=string:192.168.200.1```
[File](undefined)


### windows
> [How to Setup Wireguard VPN Server On Windows - Henry's Portal](https://www.henrychang.ca/how-to-setup-wireguard-vpn-server-on-windows/)

> [PowerShell says "execution of scripts is disabled on this system."](https://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system)

### wsl2
> [Installing WireGuard in WSL 2](https://centerorbit.medium.com/installing-wireguard-in-wsl-2-dd676520cb21)

> [WSL 2 does not have /lib/modules/](https://unix.stackexchange.com/questions/594470/wsl-2-does-not-have-lib-modules)






