本文介绍:

Azure Database for MySQL 安全连接的第三种方式:Private endpoint connections

案例:创建MySQL private endpoint connection;

           在相同VNET里的VM里通过private endpoint 连接到MySQL;

           跨VNET的 VM无法通过private endpoint 连接到MySQL;

图文步骤:

 

(一)禁用公网访问:

Deny public network access 设置为Yes

Azure Database for MySQL Connection Security -(3) Private Endpoint

 


 

(二)创建Private endpoint connection

创建Private endpoint的两个入口:

入口(1)从MySQL页面创建 private endpoint

 

Azure Database for MySQL Connection Security -(3) Private Endpoint

 

入口(2)Private link center 入口创建 private endpoint

Azure Database for MySQL Connection Security -(3) Private Endpoint

选择资源组,设定Name,选择Region:

Azure Database for MySQL Connection Security -(3) Private Endpoint

选择“create private endpoint”按钮:

 

本例中Resource Type选择“Microsoft.DBforMySQL/servers”,  然后在下拉列表中选择要设置的MySQL服务器,Target sub-resource 默认为mysqlServer:

Azure Database for MySQL Connection Security -(3) Private Endpoint

选择一个虚拟网络和子网,默认会创建一个新的Private DNS Zone,按照提示将 Integration with private dns zone 设定为 yes即可:

 

Azure Database for MySQL Connection Security -(3) Private Endpoint

 


 

 

(三)验证VNET下使用Private endpoint 连接MySQL

 

创建完成后,转到资源,可以看到如下页面,本例中,为MySQL分配了一个Private IP 10.1.0.5

Azure Database for MySQL Connection Security -(3) Private Endpoint

同时在MySQL的private endpoint connection 页面可以看到如下的 connection已经创建完成:

Azure Database for MySQL Connection Security -(3) Private Endpoint

 

 

在资源组中,可以找到已经创建的Private endpoint 和 Private DNS Zone:

 

Azure Database for MySQL Connection Security -(3) Private Endpoint

 

点击Private DNS Zone进入,可以看到增加了一条A记录,A记录是域名到IP的绑定,如下图所示,Private link的域名应该是标注1 和标注 2的 组合:

本例中应该为:sean-mysql.privatelink.mysql.database.azure.com

 

Azure Database for MySQL Connection Security -(3) Private Endpoint

 

 

测试从专用IP地址(内网IP)或Private link的 域名 连接到MySQL:

本例中选择 Private endpoint 相同的 VNET下的一台VM,注意,此VM和private endpoint 在不同的 子网中:

本立中使用 sean-mysql.privatelink.mysql.database.azure.com 或者 10.1.0.5 都可以访问MySQL服务器

Azure Database for MySQL Connection Security -(3) Private Endpoint

 

在虚拟机中使用nslookup sean-mysql.privatelink.mysql.database.azure.com,查看 域名解析情况,得到 如下图内网专用IP:

Azure Database for MySQL Connection Security -(3) Private Endpoint

 

使用跨VNET的VM通过private endpoint 连接MySQL:

因为配置private endpoint时 将Deny public network access 设置为Yes,无法连接,提示如下:Client with IP "xxx" is not allowed to connect to this MySQL server.

Azure Database for MySQL Connection Security -(3) Private Endpoint

 

相关文章:

  • 2021-10-26
  • 2021-07-31
  • 2022-01-07
  • 2022-12-23
  • 2021-11-09
  • 2021-08-05
  • 2022-12-23
猜你喜欢
  • 2021-04-28
  • 2021-08-21
  • 2022-12-23
  • 2022-03-08
相关资源
相似解决方案