π Day 8 β Inbound & Outbound Rules in AWS Security Groups
Security Groups act as a virtual firewall in AWS that protect EC2 instances from unwanted traffic and ensure secure communication.
Today, I learned how Inbound and Outbound rules work β a critical skill for deploying secure applications in real DevOps workflows.---
AWS Networking β EIP + Inbound + Outbound Rules
π¦ What is Elastic IP (EIP)?
Feature
Description
IP Type
Static Public IPv4
Changes on reboot?
β No β Always same IP
Attach/Detach
β Yes (between EC2 or ENI)
Usage
Public-facing workloads
Why is EIP needed?
Issue with normal Public IP
EIP Solution
IP changes on stop/start
Fixed Public IP avoids breakage
DNS mapping breaks
Stable IP for web apps
Can't maintain public connectivity
Reliable customer access
Where EIP is used?
Use Case
Reason
Web Servers
Same public IP always
Bastion Hosts
Secure admin access
NAT Instances
Private subnet β Internet
VPN Gateways
Stable connection point
AWS Console Steps
Step
Action
1
Go to EC2 β Elastic IPs β Allocate
2
Select Allocate IP
3
Associate with EC2/ENI
4
Add SG rules to allow public access
π EIP is free only when attached to a running instance.
π Security Groups (SG) β Firewall for EC2 Services
Direction
Controls
Default
Inbound
Traffic coming into EC2
Deny All
Outbound
Traffic going out from EC2
Allow All
β¬οΈ Inbound Rules β Entering EC2
Port
Protocol
Source
Purpose
22
SSH
My Public IP
Secure instance login
80
HTTP
0.0.0.0/0
Public website access
443
HTTPS
Anywhere
Secure web access
3306
MySQL
App-SG only
Protect DB from Internet
π If a port isn't allowed β access blocked
Example Traffic Flow:
Internet β Allow 80 β Web Server EC2
Admin β Allow 22 β EC2
App Server SG β Allow 3306 β Database EC2
β¬οΈ Outbound Rules β Leaving EC2
Use Case
Why Needed
System Updates
Install packages
API Calls
App to external services
DB Connection
App to database
NAT Access
Private β Internet
Rule
Meaning
Allow All Outbound
Normal EC2 networking
Restrict to DB Port
EC2 can talk only to DB
π Default: Allow All Outbound
π Security Group Traffic Flow
β¬ Allowed Inbound
Internet ------------------> EC2 Instance
β¬ Allowed Outbound
Top comments (0)