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

Why EC2 instance continues responding to a ping request after deleting the inbound security group rule?

· 52CE 我爱测

While playing around with AWS console, I tried the following Launched an EC2 instance (public IP enabled) in the default VPC with the default security group, and default subnet. EC2 launched in the default subnet with a public IP…

问题原文

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

While playing around with AWS console, I tried the following

  1. Launched an EC2 instance (public IP enabled) in the default VPC with the default security group, and default subnet.
  2. EC2 launched in the default subnet with a public IP.
  3. pinged the EC2 instance from the command prompt using the public IP.
  4. got request timed out.
  5. noticed that the default security group inbound rule allows traffic only from the sources within the security group.
  6. modified the security group inbound rule and allowed traffic from anywhere (0.0.0.0/0)
  7. pinged the EC2 instance using the public IP again.
  8. got a response from the server. All good until now.
  9. ping reply from EC2 host continues to show up in the console.
  10. I deleted the inbound security group rule. Now there are no inbound rules for the security group.
  11. on the terminal, reply from EC2 instance continues to show.

My question is - Why I am seeing a reply from the host (EC2 instance) even though the security group's inbound rule has been deleted?

Doesn't the change to the inbound security group rule applies immediately? Why the host (EC2 instance) continues responding without an inbound security group rule?

已采纳解答

原帖链接 · Michael - sqlbot · CC BY-SA 4.0

The change applies immediately, but security group rules control establisment of new traffic flows (identified by source and destination address, protocol, and port numbers for protocols that use port numbers).

Depending on the specific rule in question, flows may or may not be actively tracked by the network, but ICMP flows are always tracked. Once a tracked flow is established, the flow no longer needs to match a rule because the network has created a state table entry for the flow that will persist until the network removes it, either due to an inactivity timeout or due to a close/reset for connection-oriented protocols like TCP.

Tracked flows are not disrupted by removal of the rule that allowed them to be created.

Stop the ping and restart it. If it continues to work, stop it and wait a few seconds before restarting it. You should find that shortly after removing the rule, a new attempt to ping the target instance results in a timeout.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#security-group-connection-tracking

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

资料来源与适用范围

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

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

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