【问题标题】:EC2 Block All Outbound callsEC2 阻止所有出站呼叫
【发布时间】:2014-05-12 05:55:45
【问题描述】:

我有一个 ec2 虚拟机,它是我从 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

【问题讨论】:

  • 你是在经典还是 VPC 中运行这个?
  • 是类VM,不是VPC

标签: amazon-ec2 centos iptables offlineapps


【解决方案1】:

如果您使用的是 EC2-classic,则无法更改出站规则。只有 EC2-VPC 允许您在安全组中配置出站流量。此外,安全组规则始终是permissive;您不能创建拒绝访问的规则。请查看在 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 访问的教程。

【讨论】:

  • 谢谢!是的,我使用的是 ec2-classic VM,我使用 iptables 解决了这个问题。我从这个链接crm.vpscheap.net/… 应用了 1、2、4、6 和 14(我不需要设置 DNS),它成功了,谢谢!
猜你喜欢
  • 1970-01-01
  • 2017-02-14
  • 1970-01-01
  • 2011-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-23
  • 1970-01-01
相关资源
最近更新 更多