Establish a VPN connection in cmd

后端 未结 3 1813
渐次进展
渐次进展 2020-12-13 13:10

How can I create a VPN connection with an arbitrary server using an arbitrary protocol in Windows cmd?

3条回答
  •  孤城傲影
    2020-12-13 13:10

    Is Powershell an option?

    Start Powershell:

    powershell
    

    Create the VPN Connection: Add-VpnConnection

    Add-VpnConnection [-Name]  [-ServerAddress]  [-TunnelType  {Pptp | L2tp | Sstp | Ikev2 | Automatic}] [-EncryptionLevel  {NoEncryption | Optional | Required | Maximum}] [-AuthenticationMethod  {Pap | Chap | MSChapv2 | Eap}] [-SplitTunneling] [-AllUserConnection] [-L2tpPsk ] [-RememberCredential] [-UseWinlogonCredential] [-EapConfigXmlStream ] [-Force] [-PassThru] [-WhatIf] [-Confirm] 
    

    Edit VPN connections: Set-VpnConnection

    Set-VpnConnection [-Name]  [[-ServerAddress] ] [-TunnelType  {Pptp | L2tp | Sstp | Ikev2 | Automatic}] [-EncryptionLevel  {NoEncryption | Optional | Required | Maximum}] [-AuthenticationMethod  {Pap | Chap | MSChapv2 | Eap}] [-SplitTunneling ] [-AllUserConnection] [-L2tpPsk ] [-RememberCredential ] [-UseWinlogonCredential ] [-EapConfigXmlStream ] [-PassThru] [-Force] [-WhatIf] [-Confirm]
    

    Lookup VPN Connections: Get-VpnConnection

    Get-VpnConnection [[-Name] ] [-AllUserConnection]
    

    Connect: rasdial [connectionName]

    rasdial connectionname [username [password | \]] [/domain:domain*] [/phone:phonenumber] [/callback:callbacknumber] [/phonebook:phonebookpath] [/prefixsuffix**]
    

    You can manage your VPN connections with the powershell commands above, and simply use the connection name to connect via rasdial.

    The results of Get-VpnConnection can be a little verbose. This can be simplified with a simple Select-Object filter:

    Get-VpnConnection | Select-Object -Property Name
    

    More information can be found here:

    • Manage VPN Connections in Windows 8 by Using Windows PowerShell
    • Rasdial
    • Select-Object

提交回复
热议问题