How to configure a firewall on Ubuntu?

Member

by alivia , in category: Networking & Wireless , 2 years ago

How to configure a firewall on Ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by ethelyn , 2 years ago

@alivia 

Configuring a firewall on Ubuntu can be done using the built-in firewall tool called ufw (Uncomplicated Firewall). Here are the steps to configure a firewall on Ubuntu:

  1. Check if ufw is installed by running the following command:
1
sudo ufw status


If it's not installed, you can install it by running the following command:

1
sudo apt-get install ufw


  1. Set the default incoming policy to deny:
1
sudo ufw default deny incoming


  1. Allow incoming traffic for specific ports and protocols. For example, to allow incoming traffic for SSH (port 22) and HTTP (port 80), run the following commands:
1
2
sudo ufw allow ssh
sudo ufw allow http


  1. Enable the firewall:
1
sudo ufw enable


  1. Verify the firewall status by running the following command:
1
sudo ufw status


That's it! You have successfully configured a firewall on your Ubuntu machine using ufw.

Member

by ethelyn , 5 months ago

@alivia 

Configuring a firewall on Ubuntu can be done using a tool called UFW (Uncomplicated Firewall). Here are the steps to configure UFW on Ubuntu:

  1. Check if UFW is installed by running the following command:
1
sudo ufw status


  1. If UFW is not installed, you can install it by running:
1
2
sudo apt update
sudo apt install ufw


  1. Set the default policies to deny incoming and allow outgoing traffic:
1
2
sudo ufw default deny incoming
sudo ufw default allow outgoing


  1. Allow specific incoming traffic, for example, allow SSH (port 22) and HTTP (port 80):
1
2
sudo ufw allow ssh
sudo ufw allow http


  1. If you are connecting to the server via SSH, make sure to also allow SSH connections on the port you are connected to before enabling UFW. Otherwise, you may get locked out.
  2. Enable the firewall:
1
sudo ufw enable


  1. Verify the firewall status and rules:
1
sudo ufw status


You should see the rules you've set up displayed on the terminal.


Remember to adjust the firewall rules according to your specific requirements and services running on your Ubuntu system.