How to configure a firewall on Ubuntu?

Member

by alivia , in category: Networking & Wireless , a year ago

How to configure a firewall on Ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by ethelyn , a year 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.