简体   繁体   English

通过 VPC 对等连接到 RDS

[英]Connect to RDS through VPC Peering

I am trying to connect to an RDS Instance from my local machine through a VPC Peering connection.我正在尝试通过 VPC 对等连接从我的本地计算机连接到 RDS 实例。 In my AWS Account I have two VPCs: VPC1 is connected to my local.network via DirectConnect, VPC2 isn't.在我的 AWS 账户中,我有两个 VPC:VPC1 通过 DirectConnect 连接到我的 local.network,而 VPC2 没有。 VPC2 contains all of my infrastructure and the idea is that if I want to connect to that infrastructure from my local machine I need to work through VPC1. VPC2 包含我所有的基础设施,我的想法是,如果我想从我的本地机器连接到该基础设施,我需要通过 VPC1 工作。

I have configured a route in the peering connection to forward IP based requests to VPC2 for a given address range.我在对等连接中配置了一条路由,以将基于 IP 的请求转发到给定地址范围内的 VPC2。 This doesn't really help me for RDS though because I don't know what the IP Address for RDS is, only the endpoint.这对 RDS 并没有真正帮助我,因为我不知道 RDS 的 IP 地址是什么,只是端点。 I am guessing that there is some combination of DNS/Routing/Networking/Peering that will solve this problem but I haven't found any documentation that describes how to solve this issue.我猜测有一些 DNS/路由/网络/对等组合可以解决这个问题,但我还没有找到任何描述如何解决这个问题的文档。

Has anyone solved this issue before, or know of any documentation that describes what needs to be done?有没有人以前解决过这个问题,或者知道任何描述需要做什么的文档?

Update: The exact problem is that I can't connect to the RDS instance from my local machine.更新:确切的问题是我无法从本地计算机连接到 RDS 实例。 For example, if I use the RDS Endpoint as the server for my connection, the Sql Client I am using simply can't connect with a timeout error.例如,如果我使用 RDS 端点作为我的连接服务器,我使用的 Sql 客户端根本无法连接并出现超时错误。 My suspicion is that traffic is not being routed to VPC2 correctly but I don't know how to prove that.我怀疑流量没有正确路由到 VPC2,但我不知道如何证明这一点。

As far as DNS goes, I am not sure how OnPrem is setup however I have 4 hosted zones in Route53 with a variety of URLs.就 DNS 而言,我不确定 OnPrem 是如何设置的,但是我在 Route53 中有 4 个具有各种 URL 的托管区域。 Items that I setup in Route53 I am able to resolve by host name on my local.我在 Route53 中设置的项目我可以在本地通过主机名解析。

Likewise, I am not sure how the.network has been configured with DirectConnect (full VPN tunnel or otherwise).同样,我不确定如何使用 DirectConnect(完整的 VPN 隧道或其他方式)配置 .network。

As far as DNS and the.network connections between AWS go though, that stuff works.至于 DNS 和 AWS go 之间的 .network 连接,这些东西是有效的。 I am able to resolve pieces of infrastructure in VPC1 fine I just (seemingly) can't get traffic to move across the Peering Connection in the way that I would expect.我能够很好地解析 VPC1 中的基础设施片段,我只是(似乎)无法让流量以我期望的方式在对等连接之间移动。

Sorry for the Japanese material.对不起日本材料。

I think VPC1 and VPC2 cannot communicate even if you configure routing.我觉得VPC1和VPC2即使配置了路由也不能互通。 So as long as communication is impossible, configuring DNS will not accomplish the goal, I guess.因此,只要无法通信,配置 DNS 就无法实现目标,我猜。

AWS Solutions Architect ブログ: VPC Peeringの使いどころとTips等々 AWS 解决方案架构师 ブログ: VPC Peeringの使いどころとTips等〇

VPC Peering provides peering, not routing between multiple VPCs, so if you are peering 3 or more VPCs or connecting to locations outside of AWS via VPN or DirectConnect, even if you set the Routing Table appropriately for each, there will be no IP layer routing to.networks more than 2 hops away. VPC Peering 提供对等连接,而不是多个 VPC 之间的路由,因此如果您正在对等连接 3 个或更多 VPC 或通过 VPN 或 DirectConnect 连接到 AWS 外部的位置,即使您为每个设置适当的路由表,也不会有 IP 层路由to.networks 距离超过 2 跳。 Even if you configure the Routing Table appropriately, there will be no IP layer routing to.networks more than 2 hops away.即使您适当地配置了路由表,也不会有 IP 层路由到 .networks 超过 2 跳。 Workarounds such as using proxies or stepping stones are required as before.像以前一样需要使用代理或垫脚石等变通办法。

Translated with www.DeepL.com/Translator (free version)www.DeepL.com/Translator翻译(免费版)

Could PrivateLink help you achieve your goal? PrivateLink 能否帮助您实现目标?

AWS-40_AWS_Summit_Online_2020.NET01.pdf AWS-40_AWS_Summit_Online_2020.NET01.pdf

Along the example on page 42:根据第 42 页的示例:

local.network --> Direct Connect --> VPC Endpoint (in VPC1) --> NLB (in VPC2) --> RDS (in VPC2) local.network --> Direct Connect --> VPC Endpoint(在 VPC1 中)--> NLB(在 VPC2 中)--> RDS(在 VPC2 中)

I think the problem is that you think you can access vpc2 resources from on-prem just b/c you have direct connect to vpc1.我认为问题在于您认为您可以从本地访问 vpc2 资源,只需 b/c 您直接连接到 vpc1。 What vpc-peering is giving you is access from vpc1 to vpc2 via private ip addresses. vpc-peering 为您提供的是通过私有 ip 地址从 vpc1 访问 vpc2。 In your case you want vpc1 to act like a router to just transit your request from on-prem to vpc2.在您的情况下,您希望 vpc1 像路由器一样将您的请求从本地传输到 vpc2。 It does not work that way.它不是那样工作的。

What are your options:你有什么选择:

  • You could have a host vpc1 access vpc2 (like a bastion host) and you could ssh into that one first.您可以让主机 vpc1 访问 vpc2(如堡垒主机),您可以先将 ssh 放入该主机。
  • If possible, you can create a vpn connection from on-prem to vpc2.如果可能,您可以创建从本地到 vpc2 的 vpn 连接。
  • And there are more complex solutions via transit gateway.通过中转网关还有更复杂的解决方案。

The doc here talks about vpc-peering limitations, it will basically explain that transitive connections like you want won't work: https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-basics.html这里的文档讨论了 vpc 对等限制,它基本上会解释像你想要的传递连接不起作用: https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-basics.html

AWS scenario documentation to reach db mentions option 1 here: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Scenarios.html到达数据库的 AWS 场景文档在此处提到了选项 1: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Scenarios.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM