用于配置虚拟网络网关的 Azure-cli 命令

Azure-cli commands to configure a Virtual network gateway

用于配置点到站点 VPN 设置的 azure-cli 命令是什么?

我在通过门户网站执行这些步骤的代码中寻找等效的 az:

- From the settings section for a Virtual network gateway
- Click on Point-to-site configuration settings
- Set address pool, tunnel type, authentication type, and a root certificate
- Save
- Download VPN Client (vpnconfig.ovpn file)

要通过Azure CLI 命令创建虚拟网络网关,您可以按照Create a route-based VPN gateway using CLI中的步骤进行操作。但是到了创建虚拟网关的步骤,你应该多加一些参数。

--地址前缀

Space-表示 P2S 客户端地址 space 的 CIDR 前缀分隔列表。

--客户端协议

用于连接的协议。

接受的值:IkeV2、OpenVPN、SSTP

所以完整的命令如下所示:

az network vnet-gateway create \
  -n VNet1GW \
  -l eastus \
  --public-ip-address VNet1GWIP \
  -g TestRG1 \
  --vnet VNet1 \
  --gateway-type Vpn \
  --sku VpnGw1 \
  --vpn-type RouteBased \
  --address-prefixes 192.168.0.0/24 \
  --client-protocol OpenVPN

然后需要上传根证书的证书:

az network vnet-gateway root-cert create -g TestRG1 -n vpncliCert --gateway-name VNet1GW --public-cert-data path/to/your/certificate

一切正常后,就可以下载VPN客户端使用了。不要忘记在您的计算机中安装根证书的客户端证书。