Core lesson 16 of 18Topic: VPC: routing and traffic controls
Read EC2 security group rules: direction, ports and source scope
An EC2 security group (SG) contains allow rules for traffic reaching or leaving associated resources. Match direction, protocol, port and peer to the required connection. Even for SSH (Secure Shell), establish the connection method and actual source before considering a rule for port 22.
Explain what one SG rule permits and inspect its resource association, other associated groups and host-side conditions.
Distinguish VPC routing from traffic controls. No real SG changes, IP submissions or private keys are needed.
Match four rule fields to the request
| Field | Question | Illustrative condition |
|---|---|---|
| Direction | Is this a new inbound or outbound request? | SSH toward EC2 is inbound at its destination |
| Protocol | TCP, UDP or another protocol? | Ordinary SSH uses TCP |
| Port | Which port does the destination listen on? | 22 if the configured SSH listener uses port 22 |
| Peer | Inbound source or outbound destination? | Limit it to the required management source |
Read inbound and outbound relative to the resource associated with the SG. The same request is outbound at the source and inbound at the destination. The person using the console is not the reference point for direction.
Read the SG together with its actual resource association
- Management source → Inbound allow ruleIdentify the required peer and traffic.
- Inbound allow rule → EC2 network interfaceRead the rules actually associated with the target resource.
- Management source
- The connection method affects which peer the SG must match.
- Inbound allow rule
- Inspect direction, protocol, port and source.
- EC2 network interface
- Check SGs on the actual elastic network interface (ENI); OS listening and authentication are separate.
When several SGs are associated with the same resource, their rules are aggregated. Do not conclude “not allowed” after reading just one group. Conversely, narrowing one group may not achieve the intended restriction while another associated group still grants broad access.
Stateful responses do not allow every new request
SGs are stateful and handle responses to permitted traffic using connection state. That does not authorize arbitrary new requests. It also does not automatically satisfy network ACLs (NACLs), host firewalls, listeners or SSH authentication.
Limit the source and review the impact of changes
- Establish the connection method, destination, port and required source.
- Read all SGs associated with the target ENI and their allow rules.
- Before changing a shared group, inspect its other associated resources.
- Verify routing, NACLs and host behavior separately.
Choose an option to see the result and explanation.
Do not diagnose an SSH timeout from SGs alone
After reading the relevant SG rules, investigate routes, NACLs, OS listeners, login identity and authentication method. The SSH troubleshooting lesson separates timeouts, refused connections and authentication errors to choose the next check.
Check, then explain in your own words
- Read direction, protocol, port and peer.
- Inspect every associated security group.
- Separate the SG condition from end-to-end SSH success.
Check your understanding: Should the first response to an SSH timeout be opening port 22 to everyone?
No. Establish the connection method and required source first.
Broad access does not replace diagnosis. Review the intended scope, other controls and the impact of a proposed change before acting.
Sources and conditions checked
The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.
- VPC security groupsChecked:
Scope and conditionsStateful resource traffic controls
Used in this lessonMatch four rule fields to the request Read the SG together with its actual resource association Stateful responses do not allow every new request Limit the source and review the impact of changes
Scope and conditionsConnection mode, network, host and authentication must be separated
Used in this lessonMatch four rule fields to the request Read the SG together with its actual resource association Stateful responses do not allow every new request Limit the source and review the impact of changes
- VPC network ACLsChecked:
Scope and conditionsStateless subnet boundary controls; rule order and return traffic
Used in this lessonStateful responses do not allow every new request
- Security group rulesChecked:
Scope and conditionsAllow-rule fields, associated-rule aggregation and effects of changes; not universal application reachability.
Used in this lessonMatch four rule fields to the request Read the SG together with its actual resource association Stateful responses do not allow every new request Limit the source and review the impact of changes