Как использовать PowerShell для подключения IPSec VPN IKEv2?

Чтобы проверить соединение IPSec, я использовал клиентскую реализацию StrongSwan с Ubuntu 16 без пользовательского интерфейса.

Можно ли использовать только PowerShell для создания и тестирования VPN-соединения?

Доступные активы:

  • общедоступная конечная точка VPN, то есть IP
  • имя пользователя
  • пароль
  • PSK (закрытый общий ключ)

person Open Food Broker    schedule 27.12.2019    source источник


Ответы (1)


Этот сценарий предназначен для cert-auth, но вы можете изменить:

# Set these to the correct values
$server_address = "vpn.example.com"
$connection_name = "VPN Connection"
$certificate_path = "certificate.p12"
$ca_cert_path = "strongswanCert.pem"
$password = ConvertTo-SecureString -String "P12 passphrase" -AsPlainText -Force

# Import machine cert
Import-PfxCertificate -FilePath $certificate_path -CertStoreLocation Cert:\LocalMachine\My\ -Password $password

# Import CA root
Import-Certificate -FilePath $ca_cert_path -CertStoreLocation Cert:\LocalMachine\Root\

# Add VPN connection IKEv2 with machine cert
Add-VpnConnection -Name $connection_name -ServerAddress $server_address -TunnelType Ikev2 -EncryptionLevel Required -AuthenticationMethod MachineCertificate -AllUserConnection

# Add IPv6 default route (::/0 does not work)
Add-VpnConnectionRoute -ConnectionName $connection_name -DestinationPrefix ::/1
Add-VpnConnectionRoute -ConnectionName $connection_name -DestinationPrefix 8000::/1
person Piotr    schedule 17.09.2020
comment
привет спасибо за обмен! как вы имеете в виду, сертификат-auth? - person Open Food Broker; 17.09.2020