(混合云:本地计算机可以连接到Azure的虚拟网络上)
第一步:创建虚拟网络
![图片[1]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/7T%40LKTVV_2AV7DZ%40SGJ-1024x631.png)
![图片[2]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image.png)
![图片[3]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-3.png)
第二步:在虚拟网络中加入一个虚拟网关子网
分配给网关子网的IP地址不能小于3个
注意:网关子网不需要更改名字,只需分配一个网络地址块
![图片[4]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-4.png)
可选操作:Azure内网2台虚拟机可通过IP或DNS域名进行通信,如果需要,可自定义部署DNS服务器
![图片[5]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-5.png)
第三步:创建虚拟网关,加入到虚拟网络中
![图片[6]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-6.png)
虚拟网络网关类型分为 2 种:VPN、ExpressRoute
点到站点VPN:VPN虚拟网关(一般点到站点VPN网络连接不需要专用的路由和设备,采用普通的VPN类型虚拟网关即可满足需求;)
站点到站点VPN:ExpressRoute (要求本地网络与云端虚拟网络连接速度较快则采用ExpressRoute类型网关)
VPN类型分为基本路由Route-based 、策略路由Policy-based (大多采用基于路由)
SKU:网关计价方式 (基本、标准、高性能)
![图片[7]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-7.png)
选择属于哪个虚拟网络
![图片[8]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-8.png)
第四步: 生成自签名根证书
证书2种生成方式: PowerShell、 Windows自带命令makecert
方法一: Windows自带命令makecert
D:\makecert -sky exchange -r -n "CN=P2SRootCert1102" -pe -a sha256 -len 2048 -ss My
D:\makecert -n "CN=P2SClientCert1102" -pe -sky exchange -m 96 -ss My -in "P2SRootCert1102" -is my -a sha256
生成的证书自动保存在证书管理器内,手动将它导出,运行命令:certmgr.msc
![图片[9]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-9.png)
![图片[10]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-10-1024x593.png)
注意:导出选择Base64 编码格式
![图片[11]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-11-1024x697.png)
使用记事本打开:
![图片[12]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-12-1024x719.png)
注意:由于Azure让其输入证书的类型属于单行文本框,需要手动将证书的换行符去掉
方法二:使用PowerShell创建根证书
$cert = New-SelfSignedCertificate -Type Custom -KeySpec Signature ' -Subject "CN=证书名" -KeyExportPolicy Exportable ' -HashAlgorithm sha256 -KeyLength 2048 ' -CertStoreLocation "Cert:\CurrentUser\My" -KeyUsageProperty Sign -KeyUsage CertSign
使用根证书,生成客户端证书
New-SelfSignedCertificate -Type Custom -KeySpec Signature ' -Subject "CN=P2SChildCert" -KeyExportPolicy Exportable ' -HashAlgorithm sha256 -KeyLength 2048 ' -CertStoreLocation "Cert:\CurrenUser\My" ' -Signer $cert -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2")
第五步:进入已创建的虚拟网络网关
点击进入站点到站点的VPN连接配置(不能与本地IP地址段冲突!)
![图片[13]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-2-1024x553.png)
![图片[14]-Azure配置点到站点的VPN-](https://fbi.kim/wp-content/uploads/2019/11/image-1-1024x556.png)