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, 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.

Apr 30, 2025 - 17:36
 0
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, 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.