Skip to main content

Command Palette

Search for a command to run...

πŸ”₯ Day 7 of My DevSecOps Journey

Published
β€’3 min read
πŸ”₯ Day 7 of My DevSecOps Journey

UFW Firewall, IPTables, Port Management, Connectivity, Troubleshooting & Real DevOps Scenarios (Full Guide)

Today was all about understanding how VM-level firewalls work using UFW (Uncomplicated Firewall) and why it’s preferred over traditional IPTables.
I also performed a hands-on practical using Java + Maven, tested port access, and learned multiple real-world troubleshooting techniques.

Let’s break down everything I learned πŸ‘‡


πŸ” 1️⃣ Why Do We Need UFW When We Already Have Security Groups?

Security Groups (AWS/GCP/Azure) control firewall rules at the network level.

But inside the VM, we still need internal firewall protection.

πŸ”Έ Traditional Approach β†’ IPTables

While powerful, IPTables is complex:

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

Not beginner-friendly. Hard to remember. Error-prone.

πŸ”Έ Modern Approach β†’ UFW

UFW = Human-friendly wrapper over IPTables

sudo ufw allow 22

Much cleaner, easier, and safe for daily DevOps use.


🚦 2️⃣ UFW Fundamentals β€” Simple, Clean & Effective

βœ”οΈ Allow a port

sudo ufw allow 22

❌ Deny a port

sudo ufw deny 22

πŸ” Specify direction

By default, UFW assumes incoming traffic.

To specify direction:

  • Incoming:

      sudo ufw allow in 22
    
  • Outgoing:

      sudo ufw deny out 443
    

πŸ“œ 3️⃣ Default UFW Policies

These policies define VM behavior:

  • Incoming: deny

  • Outgoing: allow

Can be changed using:

sudo ufw default deny incoming
sudo ufw default allow outgoing

πŸ§ͺ 4️⃣ Hands-On Practical β€” Testing UFW With Java + Maven

I conducted a full demo to see UFW in action:

πŸ”§ Installed:

βœ”οΈ Java
βœ”οΈ Maven

🧬 Cloned a board-game project (GitHub)

git clone <repo>

🚧 Issue: mvn package failed

Why?
Because the incoming port required by the application was blocked.

βœ”οΈ Enabled incoming traffic using UFW

sudo ufw allow <required-port>

The application started working after allowing the port.

βœ‹ Disabled the port again

Saw UFW reject the connection immediately.


🚦 5️⃣ Types of Firewall Behaviors in UFW

1️⃣ Allow β†’ Connection works normally
2️⃣ Deny β†’ Silent timeout
3️⃣ Reject β†’ Immediate error (host unreachable)


πŸ“ 6️⃣ Adding Comments to UFW Rules

Useful for teams β€” makes rules readable:

sudo ufw allow 80/tcp comment "http"

Delete rule:

sudo ufw delete allow 80/tcp

Allow specific IP:

sudo ufw allow proto tcp from <IP> to any port <port>

πŸ”§ 7️⃣ Troubleshooting Scenarios I Learned Today

These are real DevOps issues that happen daily:


πŸŸ₯ Issue 1 β€” Packages not installing

Cause: Outbound rules blocked, system cannot reach the internet.

βœ”οΈ Fix: Add outbound allow rules.


🟧 Issue 2 β€” docker.io or other package says: β€œno installation candidate”

Two possible causes:

  1. Didn’t run:

     sudo apt update
    
  2. Package deprecated/unavailable in repo.


🟦 Issue 3 β€” SSH connection not working

Check if port 22 is open:

telnet <IP> 22

🟩 Issue 4 β€” Port already in use

Find the process:

sudo lsof -i :8080

πŸŸͺ Issue 5 β€” Check VM disk usage

du -sh
du -kh

🟨 Issue 6 β€” Permission problems

Add users to required groups:

sudo usermod -aG <group> <user>

🎯 Day 7 Takeaway

Today’s learning strengthened my understanding of:

βœ”οΈ VM-level firewalls
βœ”οΈ UFW vs IPTables
βœ”οΈ Port management
βœ”οΈ Allow / deny / reject behavior
βœ”οΈ Connectivity troubleshooting
βœ”οΈ SSH debugging
βœ”οΈ Storage checks
βœ”οΈ Permission fixes
βœ”οΈ Real DevOps debugging skills

Firewall management plays a huge role in secure application deployments, server protection, and cloud environments β€” and today helped me understand it with real, practical scenarios.

Looking forward to Day 8! πŸš€

More from this blog

D

DevSecOps - Zero To Hero

19 posts