gpt4 book ai didi

amazon-ec2 - EC2 阻止所有出站调用

转载 作者:太空宇宙 更新时间:2023-11-03 17:14:22 28 4
gpt4 key购买 nike

我有一个 ec2 VM,它是我从 VMWare 实例导出的 CentOS 机器。与此 VM 关联的安全组是默认安全组,此默认安全组仅启用了入站设置,我无法编辑该组的出站设置(它在 ec2 仪表板中显示为已禁用)不知道为什么。

我想做的是阻止来自机器内部的所有出站调用,我有一个应用程序并试图模拟在离线环境中运行它,它可以接受来自 VM 外部的调用,但不能在外部进行任何调用虚拟机。

有没有办法在 ec2 VM 中实现这个?我不确定此时我可以提供哪些信息以便获得最佳帮助,因此请向我询问任何其他信息。

iptables 目前在 VM 中停止,如果我启动它,它将阻止对 VM 的所有入站调用,我将无法访问该应用程序(它是 Web 应用程序)。

这是 iptables -L 的输出

[root@ip-10-154-146-78 app_module]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

最佳答案

如果您使用的是 EC2-classic,则无法更改出站规则。只有 EC2-VPC 允许您在安全组中配置出站流量。此外,安全组规则始终是宽松的;您不能创建拒绝访问的规则。请查看在 EC2-VPC 中使用网络 ACL。它支持入站/出站流量的允许规则和拒绝规则。但是,它在子网级别而不是实例级别运行。如果您在 VPC 子网中只启动一个实例并相应地配置 ACL,它应该可以满足您模拟测试用例的要求。使用 IPTables 也是一种选择。教程可见http://www.cyberciti.biz/tips/linux-iptables-11-how-to-block-or-open-httpweb-service.html关于如何使用 iptables 允许 http/https 访问。

关于amazon-ec2 - EC2 阻止所有出站调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22786223/

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