Windows Server Core 2022--安装PPTP/L2TP

古人学问无遗力,少壮工夫老始成。这篇文章主要讲述Windows Server Core 2022--安装PPTP/L2TP相关的知识,希望能为你提供帮助。
1.安装/配置Server Core 2022:
a.修改电脑名称:
Rename-Computer -NewName "VPN" -Restart -Force
b.配置IP/DNS:
Get-NetIPAddress
New-NetIPAddress -InterfaceIndex 5 -IPAddress 10.11.12.222   -PrefixLength 24 -DefaultGateway 10.11.12.1
Set-DNSClientServerAddress -InterfaceIndex 5 -ServerAddress "10.11.12.10,223.5.5.5"
c.加入域:
Add-Computer -DomainName nipit.cn -Credential n\\gazh -Restart -Force
备注:我之前因为安装 Server Core的时候关闭了系统的IPv6,这里在安装 RemoteAccess之前,得重新启用IPv6,否则连接VPN时会报错。(系统默认的可略过)
Set-ItemProperty -Path "HKLM:\\SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters" -Name "DisabledComponents" -Value 32
2.安装RemoteAccess组件:
Install-WindowsFeature   -Name RemoteAccess,DirectAccess-VPN,Routing -IncludeManagementTools -Restart
系统会重启。
3.安装配置VPN:
Install-RemoteAccess -VpnType Vpn -Legacy
Get-RemoteAccess

Get-VpnServerConfiguration

Get-VpnServerIPsecConfiguration

Get-RemoteAccessHealth

4.启用Windows FireWall的“Remote Access”预设的规则组:
Enable-NetFirewallRule -DisplayGroup "Routing and Remote Access"
5.在公网防火墙上开放PPTP和L2TP over IPSec的NAT规则:
For PPTP: 1723 TCP and Protocol 47 GRE (also known as PPTP Pass-through)
For L2TP over IPSEC: 1701 500 4500 UDP
For SSTP: 443 TCP


在公网防火墙上做NAT映射:

到这里就可以通过windows client 新建vpn pptp方式连接。
6.想要通过L2TP over IPSec的方式连接VPN,还需要进一下配置:
可以通过windows GUI的方式去配置:
这里通过安装有  Windows 10 的远程服务器管理工具(RSAT for Windows 10)的Windows 10客户端去配置:
打开Server Manager:
【Windows Server Core 2022--安装PPTP/L2TP】











7.配置Windows VPN客户端L2TP/IPsec连接:
由于我的VPN服务器和客户端都在NAT后面,所以默认情况下,Windows 是不能通过L2TP/IPsec连接:
??https://docs.microsoft.com/en-US/troubleshoot/windows-server/networking/configure-l2tp-ipsec-server-behind-nat-t-device??
Set-ItemProperty -Path "HKLM:SYSTEM\\CurrentControlSet\\Services\\PolicyAgent" -Name "AssumeUDPEncapsulationContextOnSendRule" -Type DWORD -Value 2 –Force

重启后,添加VPN连接:



连接成功







    推荐阅读