Advertisement
sirota

create-l2tp.ps1

Oct 20th, 2021
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. $VPNname = "test-vpn"
  2. $ServerAddress = "ip адрес или dns сервера"
  3. $VPNType = "l2tp"
  4. $l2tpPsk = "Ключ ПСК"
  5. $RemoteNetwork = "172.16.2.0/24; 192.168.1.0/24" # сюдой через ; пишем все подсети
  6.  
  7. $RemoteNetworks = $RemoteNetwork.Split(';') -replace '\s', ''
  8.  
  9. Add-VpnConnection -Name $VPNname -ServerAddress $ServerAddress -TunnelType $VPNType -L2tpPsk $l2tpPsk -SplitTunneling -Force -RememberCredential -PassThru
  10.  
  11. foreach ($RemoteNetwork in $RemoteNetworks) # Добавляем все подсети к этому VPN
  12. {
  13. Add-VpnConnectionRoute -ConnectionName $VPNname -DestinationPrefix $RemoteNetwork -PassThru
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement