gpt4 book ai didi

security - 源安全组在 AWS 中未按预期工作

转载 作者:行者123 更新时间:2023-12-03 09:44:47 25 4
gpt4 key购买 nike

我有一个 EC2 节点 node1(安全组 SG1),应该可以从端口 9200 上的另一个 EC2 节点 node2(安全组 SG2)访问。现在,当我在 SG1 中添加一个带有端口 9200 的入站规则并将 SG2 指定为源自定义 IP 部分,我无法从 node2 访问 node1。另一方面,如果我在 SG1 中指定一个入站规则,源为 0.0.0.0/0 或 node2 的 IP,则它可以正常工作。我的方法有什么问题?

最佳答案

原因:安全组间通信通过私有(private)寻址工作。如果您使用公共(public) IP 地址,防火墙规则将无法识别源安全组。

解决方案:您应该使用公共(public) DNS 记录来寻址您的实例 - 当您的一个实例查询 DNS 名称时,这实际上将指向私有(private) IP 地址。

例如如果您的实例有公共(public) IP 203.0.113.185和私有(private) IP 10.1.234.12 ,您将获得一个公共(public) DNS 名称,例如 ec2-203-0-113-185.eu-west-1.compute.amazonaws.com .
ec2-203-0-113-185.eu-west-1.compute.amazonaws.com将解析为 203.0.113.185如果从外部查询,或 10.1.234.12如果在内部查询。这将使您的安全组能够按预期工作。

这将使您能够使用弹性 IP,因为您只需使用弹性 IP 的公共(public) DNS 条目。另外,having the DNS resolve to the internal IP means that you are not incurring bandwidth charges for your data between instances :

Instances that access other instances through their public NAT IP address are charged for regional or Internet data transfer, depending on whether the instances are in the same region.

关于security - 源安全组在 AWS 中未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24232849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com