Setting up a Firewall (ufw) on a Ubuntu / Raspbian

I don’t know about you, but I don’t want a hooded cyberpunk hacker hacking into my Linux boxes. Luckily, there’s at least one layer we can add to make that much less likely happen.

Per a pretty good description and more advanced details surrounding the tool,

UFW provides a much more user-friendly framework for managing netfilter and a command-line interface for working with the firewall. On top of that, if you’d rather not deal with the command line, UFW has a few GUI tools that make working with the system incredibly simple.https://www.linux.com/training-tutorials/introduction-uncomplicated-firewall-ufw/

We’re simply going to scratch the surface and install it using the Linux terminal and configure it for a couple ports / services. Simply install it and then configure it

sudo apt install ufw

To configure UFW, we simply tell it which ports we want open and then make sure it’s up and running.

You can either allow through services (e.g. SSH, SNMP, etc.)

sudo ufw allow ssh

or specific ports (e.g. 22, 161, 8080, etc.)

sudo ufw allow 22

Now we’ll need to enable ufw to start on after boot

sudo service ufw enable

And then let’s check the status

sudo service ufw status

And that’s it! You now have a working firewall installed on your Raspberry Pi. This also works for Ubuntu and many other flavors of Linux.

Thanks for reading!

-Ade

One Comment

  1. Pingback:Installing motion on a Raspberry Pi and managing the generated files – Adrian's Personal Blog

Leave a Comment

Your email address will not be published. Required fields are marked *