Windows Server Core 2022--(3)安装PPTP/L2TP

网友投稿 2274 2022-09-16

Windows Server Core 2022--(3)安装PPTP/L2TP

Windows Server Core 2022--(3)安装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- -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映射:

配置用户Dial-In属性:allow Access

Set-ADUser -Identity Amy  -replace @{msnpallowdialin=$true}

或者:

$OUs = 'OU=Users,OU=Accounts,OU=nipit,DC=nipit,DC=cn'

$users = $OUs | Foreach {

Get-ADUser -Filter {(msNPAllowDialin -eq $false) -or (msNPAllowDialin -notlike "*")} -SearchBase $_ -Properties msNPAllowDialin,description,SamAccountName |

Select-Object Name,@{Expression={$_.SamAccountName}} | Sort-Object name

}

$user = $users | foreach {

Set-ADUser -Identity $($_.name) -replace @{msnpallowdialin=$True}

Write-Host "$($_.name) Dial-In Setting Changed" -ForegroundColor cyan

}

到这里就可以通过windows client 新建vpn pptp方式连接。

Get-RemoteAccessConnectionStatistics | Format-List -Property *

6.想要通过L2TP over IPSec的方式连接VPN,还需要进一下配置:

可以通过windows GUI的方式去配置:

这里通过安装有 Windows 10 的远程服务器管理工具(RSAT for Windows 10)的Windows 10客户端去配置:

打开Server Manager:

7.配置Windows VPN客户端L2TP/IPsec连接:

由于我的VPN服务器和客户端都在NAT后面,所以默认情况下,Windows 是不能通过L2TP/IPsec连接:

​​-Path "HKLM:SYSTEM\CurrentControlSet\Services\PolicyAgent" -Name "AssumeUDPEncapsulationContextOnSendRule" -Type DWORD -Value 2 –Force

重启后,添加VPN连接:

连接成功

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微软网站下载windows10 ISO镜像的方法
下一篇:小程序 多线程运行的优缺点?微信小程序多线程Worker怎么配置?
相关文章

 发表评论

暂时没有评论,来抢沙发吧~