Sunshine Tech and Media

How to Set up UFW on a Linux Server

ufw
ufw

UFW (Uncomplicated Firewall) is a user-friendly firewall application for Linux systems that allows you to easily configure and manage your firewall rules. This guide is for desktops/servers running Debian or a Debian-fork distribution, such as Ubuntu.

If you’re looking to set up Uncomplicated Firewall on your Linux system, here are some steps to follow:

  1. Install Uncomplicated Firewall: To install, open a terminal window and enter the following command:
sudo apt-get install ufw
  1. Enable Uncomplicated Firewall: To enable it, enter the following command:
sudo ufw enable
  1. Allow incoming connections: By default, UFW blocks all incoming connections. To allow incoming connections for a specific port or service, use the following syntax:
sudo ufw allow [port/service]

For example, to allow incoming connections on port 80 (HTTP), you would enter the following command:

sudo ufw allow 80/tcp
  1. Deny incoming connections: To block incoming connections for a specific port or service, use the following syntax:
sudo ufw deny [port/service]

For example, to block incoming connections on port 22 (SSH), you would enter the following command:

sudo ufw deny 22/tcp
  1. Allow outgoing connections: By default, UFW allows all outgoing connections. To block outgoing connections for a specific port or service, use the following syntax:
sudo ufw reject [port/service]
  1. View UFW status and rules: To view the current status of UFW and the rules that are in place, enter the following command:
sudo ufw status

This will display a list of the current rules, as well as the status of the firewall (either “active” or “inactive”).

By following these steps, you can easily set up Uncomplicated Firewall on your Linux system and configure your firewall rules to suit your specific needs. Whether you’re looking to block incoming connections, allow outgoing connections, or both, UFW provides a simple and effective way to manage your firewall.

If you are in need of VPS or domain registration services, we would recommend NameHero.

If you are interested in web design, managed hosting, or marketing services, we offer them at Sunshine Tech and Media.