👈

🔐 Firewalls and Security Concepts (Complete Guide)


1️⃣ Why Network Security Is Needed

When systems are connected to a network or the internet, they face risks such as:

  • Unauthorized access
  • Data theft
  • Malware attacks
  • Denial of Service (DoS)

👉 Security controls exist to protect systems, data, and networks.


2️⃣ What Is a Firewall?

A firewall is a security device or software that:

Monitors and controls incoming and outgoing network traffic based on predefined rules.

Think of a firewall as:

  • A security guard at the gate
  • Allowing or blocking traffic based on rules

3️⃣ Basic Firewall Concepts

🔹 Traffic Direction

  • Inbound → Traffic coming into a system
  • Outbound → Traffic going out of a system

🔹 Firewall Rule Components

A firewall rule usually includes:

  • Source IP
  • Destination IP
  • Port number
  • Protocol (TCP / UDP / ICMP)
  • Action (Allow / Deny)

4️⃣ How a Firewall Works (Simple Flow)

  1. Packet arrives
  2. Firewall checks rules (top to bottom)
  3. First matching rule is applied
  4. Packet is allowed or blocked

If no rule matches:

  • Default action applies (usually deny)

5️⃣ Types of Firewalls (Very Important)


🔵 1. Packet-Filtering Firewall

How it works:

  • Checks packet headers only
  • Uses IP, port, protocol

Pros:

  • Fast
  • Simple

Cons:

  • No awareness of connection state
  • Less secure

Example:

Allow TCP 80
Block all others

🟢 2. Stateful Firewall

How it works:

  • Tracks connection state
  • Allows return traffic automatically

Pros:

  • More secure
  • Smarter decisions

Cons:

  • More resource usage

📌 Most modern firewalls are stateful


🟠 3. Application-Layer Firewall (Layer 7)

Also known as:

  • Proxy firewall
  • Web Application Firewall (WAF)

How it works:

  • Inspects application data
  • Understands HTTP, SQL, etc.

Protects against:

  • SQL Injection
  • XSS
  • Application attacks

🔴 4. Next-Generation Firewall (NGFW)

Combines:

  • Stateful inspection
  • Application awareness
  • IDS/IPS
  • Malware detection

Used in:

  • Enterprise networks

6️⃣ Hardware vs Software Firewalls

TypeExample
HardwareNetwork firewall device
SoftwareOS firewall, cloud firewall

7️⃣ Common Security Concepts (Foundational)


🔐 CIA Triad

1️⃣ Confidentiality

  • Data is accessible only to authorized users
  • Achieved by encryption, access control

2️⃣ Integrity

  • Data is accurate and not altered
  • Achieved by hashing, checksums

3️⃣ Availability

  • Systems are accessible when needed
  • Achieved by redundancy, backups

8️⃣ Authentication vs Authorization vs Accounting (AAA)

ConceptMeaning
AuthenticationWho are you?
AuthorizationWhat can you access?
AccountingWhat did you do?

9️⃣ Common Network Attacks (High Level)

AttackDescription
DDoSOverwhelms system
Man-in-the-MiddleIntercepts data
Brute ForceTries many passwords
SpoofingFake identity

🔟 Security Zones

Networks are divided into:

  • Public zone
  • DMZ
  • Private zone

Firewalls control traffic between zones.


1️⃣1️⃣ Firewalls in AWS (Very Important)


🟣 1. Security Groups

  • Instance-level firewall
  • Stateful
  • Allow rules only

Example:

Allow TCP 22 from My IP
Allow TCP 80 from 0.0.0.0/0

🟣 2. Network ACLs (NACL)

  • Subnet-level firewall
  • Stateless
  • Allow + Deny rules

Example:

Allow inbound TCP 80
Allow outbound ephemeral ports

🟣 3. AWS WAF

  • Layer 7 firewall
  • Protects web applications
  • Works with ALB, CloudFront

🟣 4. AWS Shield

  • Protects against DDoS
  • Standard (free)
  • Advanced (paid)

1️⃣2️⃣ Security Groups vs NACL (Exam Favorite)

FeatureSecurity GroupNACL
LevelInstanceSubnet
StatefulYesNo
RulesAllow onlyAllow & Deny
DefaultDeny all inboundAllow all

1️⃣3️⃣ Principle of Least Privilege

Give minimum permissions required to perform a task.

This applies to:

  • Firewalls
  • IAM
  • Network access

1️⃣4️⃣ Defense in Depth

Use multiple layers of security:

  • Firewall
  • IAM
  • Encryption
  • Monitoring

If one fails, others protect.


1️⃣5️⃣ Encryption Basics

🔹 Data at Rest

  • Stored data
  • Encrypted using KMS, disk encryption

🔹 Data in Transit

  • Data moving over network
  • Encrypted using TLS / HTTPS

1️⃣6️⃣ Logging & Monitoring

Security requires visibility:

  • Firewall logs
  • VPC Flow Logs
  • CloudTrail

1️⃣7️⃣ Real-World Analogy

Firewall = Security gate Rules = Access policy Logs = CCTV footage


1️⃣8️⃣ One-Line Exam Definitions

Firewall:

A firewall controls network traffic by allowing or blocking packets based on security rules.

Security Group:

A stateful virtual firewall that controls EC2 traffic.


1️⃣9️⃣ Final Summary

  • Firewalls control network traffic
  • Multiple firewall types exist
  • AWS uses layered security
  • Least privilege is critical
  • Firewalls are not the only security tool