Mastering Linux Firewalls: Simple Steps to Boost Your Security!

Table of Contents

What Is a Firewall, Really?
The Main Players: iptables, firewalld, and UFW
Getting Started with UFW
A Quick Look at firewalld
Best Practices
Wrapping Up

What Is a Firewall, Really?

If you’re running a Linux system…


This content originally appeared on DEV Community and was authored by Marzena Pugo

Table of Contents

  • What Is a Firewall, Really?
  • The Main Players: iptables, firewalld, and UFW
  • Getting Started with UFW
  • A Quick Look at firewalld
  • Best Practices
  • Wrapping Up


What Is a Firewall, Really?

If you’re running a Linux system, one of the smartest things you can do is set up a firewall.

Think of a firewall as your computer’s security guard, quietly checking the traffic coming in and out, and deciding what’s allowed and what’s not.

It’s a simple concept, but it’s at the heart of keeping your system safe.

At its core, a firewall is a set of rules.

These rules tell your system which network connections to allow and which to block.

For example, you might want to let in web traffic (so you can browse or run a website) but block everything else.

Or maybe you only want to allow connections from certain IP addresses.

The firewall is your tool for making those decisions.


Getting Started with UFW

Let’s walk through a quick example using UFW, since it’s beginner-friendly and widely used.

First, check if UFW is installed:

sudo ufw status

If it’s not installed, you can add it with:

sudo apt install ufw

To turn it on:

sudo ufw enable

Now, suppose you want to allow SSH (so you can connect remotely) and web traffic (for a website):

sudo ufw allow ssh
sudo ufw allow http

You can also allow a specific port, like this:

sudo ufw allow 8080

sudo ufw status

And if you want to deny something:

sudo ufw deny 23 # This blocks Telnet, for example

A Quick Look at firewalld
If you’re on a system that uses firewalld, the process is similar but the commands are a bit different. For example, to allow HTTP traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload


Best Practices

  • Default Deny: Start by denying all incoming connections, then
    allow only what you need

  • Keep SSH Open: If you use SSH to manage your system, make sure
    you allow it before enabling the firewall, or you might lock
    yourself out

  • Review Regularly: Check your firewall rules from time to
    time. Remove anything you no longer need

  • Log Traffic: Consider enabling logging so you can see what’s
    being blocked


Wrapping Up

Setting up a firewall on Linux doesn’t have to be complicated.

Whether you use UFW, firewalld, or iptables, the important thing is to take that first step and put some basic rules in place.

Your system will be much safer for it, and you’ll have peace of mind knowing you’re in control of who can connect.


This content originally appeared on DEV Community and was authored by Marzena Pugo


Print Share Comment Cite Upload Translate Updates
APA

Marzena Pugo | Sciencx (2025-04-30T16:02:53+00:00) Mastering Linux Firewalls: Simple Steps to Boost Your Security!. Retrieved from https://www.scien.cx/2025/04/30/mastering-linux-firewalls-simple-steps-to-boost-your-security/

MLA
" » Mastering Linux Firewalls: Simple Steps to Boost Your Security!." Marzena Pugo | Sciencx - Wednesday April 30, 2025, https://www.scien.cx/2025/04/30/mastering-linux-firewalls-simple-steps-to-boost-your-security/
HARVARD
Marzena Pugo | Sciencx Wednesday April 30, 2025 » Mastering Linux Firewalls: Simple Steps to Boost Your Security!., viewed ,<https://www.scien.cx/2025/04/30/mastering-linux-firewalls-simple-steps-to-boost-your-security/>
VANCOUVER
Marzena Pugo | Sciencx - » Mastering Linux Firewalls: Simple Steps to Boost Your Security!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/04/30/mastering-linux-firewalls-simple-steps-to-boost-your-security/
CHICAGO
" » Mastering Linux Firewalls: Simple Steps to Boost Your Security!." Marzena Pugo | Sciencx - Accessed . https://www.scien.cx/2025/04/30/mastering-linux-firewalls-simple-steps-to-boost-your-security/
IEEE
" » Mastering Linux Firewalls: Simple Steps to Boost Your Security!." Marzena Pugo | Sciencx [Online]. Available: https://www.scien.cx/2025/04/30/mastering-linux-firewalls-simple-steps-to-boost-your-security/. [Accessed: ]
rf:citation
» Mastering Linux Firewalls: Simple Steps to Boost Your Security! | Marzena Pugo | Sciencx | https://www.scien.cx/2025/04/30/mastering-linux-firewalls-simple-steps-to-boost-your-security/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.