大网数据广告活动
服务器运维问答

AWS EC2 instance: security groups and firewalls

· 52CE 我爱测

On an EC2 instance, you can configure a security group to have what seem to be the same as firewall rules (e.g. default drop all traffic with selectively allowing port based, inbound or outbound traffic). Previously I've used oth…

问题原文

原帖链接 · Christian · CC BY-SA 4.0

On an EC2 instance, you can configure a security group to have what seem to be the same as firewall rules (e.g. default drop all traffic with selectively allowing port based, inbound or outbound traffic). Previously I've used other services such as DigitalOcean and I just add some rules to the firewall (e.g. UFW) once I'm logged into the instance.

With an EC2 instance should I only configure firewall rules via security groups and not touch firewall software running on the instance (e.g. once I log into the system, not configure ufw or iptables)?

I want to make sure that I've got this set up correctly, and that I'm not accidently forcing traffic through 2 sets of firewall rules if both security groups and a host based firewall is being used.

My hunch is that either approach, or a combination of both could work (and this would be fine as long as there aren't duplicate rules). Is this right? If possible I would like to simply use security groups.

已采纳解答

原帖链接 · Tim · CC BY-SA 4.0

You can use as many of or as few of the available firewalls as you like. Defense in depth suggests that more than one layer can increase security.

Here's what each is, to the best of my knowledge:

  • Network ACLs (NACLs) are the most like a traditional firewall. You have to define incoming and outgoing rules separately. I suspect that NACLs are not run on the instance, but are a device on the network somewhere. If this is correct using a NACL to reject significant amounts of traffic might slightly increase instance performance, as the security groups and IPTables doesn't have to use CPU time to do it.
  • Security Groups are a stateful firewall. If you allow incoming traffic outgoing responses are allowed automatically, and vice versa. SGs are run in the hypervisor on each server.
  • IPTables and such are (I think) stateless, so you define the rules in each direction. These run inside the operating system on your instance.

Personally I use security groups as my primary firewall as they're easiest to set up and use. I also have fail2ban putting rules into the CloudFlare firewall to prevent bad IPs accessing the server, using this setup.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-05-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。