To ensure the security of your computer, we recommend that you install a firewall to prevent others from accessing your computer and to protect you from network attacks. However, if you are a new Linux user, you may not know how to configure your system’s firewall. Learn how to configure the firewall under Linux and easily add rules that allow access to other devices on your local network or to specific ports.
UFW = single firewall
We use UFW to manage your Linux firewall because it is easy to use and is installed by default in many distributions.
In Ubuntu, ufw is switched off by default. You can check its status with a single command:
If it is not active and you want to check if it changes, use :
To disable the firewall, use :
Verification of existingimplementation rules
To view a list of applications for which the firewall has rules, use this :
You can check the open ports for these rules:
sudo ufw app info APP_NAME
Take a look at this: APP_NAME must be entered in the same way as in the previous command.
Preparation of new rules
If you want your firewall to be enabled, but you want to allow access to your computer from other devices on your local network, log in :
authorise sudo ufw of 192.168.178.0/24
In the example, remember to adjust 192.168.178.0/24 to the IP range of your local network.
To only allow access to a specific port, e.g. port 80, when using a local web server, use this port :
sudo ufw Licence of 192,168,178,0/24 in each port 80
Of course you can change port 80 to another port of your choice.
To open a number of ports on your computer with a single command, you can select
sudo ufw STARTING_PORT:Allow ENDING_PORT/PROTOCOL
For example, use it to open all ports from 50,000 to 52,000 for TCP and UDP for use with torrent clients:
sudo ufw allow 50000:52000/tcp
sudo ufw allow 50000:52000/udp
In the same way, if you already have some ports open, as has been done here for use with the popular torrent client Transmission, and want to close them, change the permission in the above command to deny them, such as
sudo ufw denial 51413:51500/udp
sudo ufw denial 51413:51500/tcp
Disable rules and reset Firewall
After installing the new rules, you can use the status command again to display all rules.
To delete rules, you must first use this command:
The list will now have a number next to each item. To delete the line, use :
Delete sudo UFW RULE_NUMBER
If you want to delete all your custom rules and restore the original firewall configuration, first disable the firewall:
Then restart the configuration with :
GUFW = GUI for UFW
If you find that the above complicates things, you can use GUFW for the graphical management of the firewall.
1. Install the GUW from the software distribution center or the package manager.
2. Start the engine.
3. To activate the firewall, click on the status button. The default rule blocks all incoming connections and allows all outgoing connections.
4. Go to the Rules tab and click on the + button below. Here you can add rules to your firewall.
If you are using your computer to access the Internet, we strongly recommend that you enable the Firewall by creating rules that allow you to use your computer securely rather than disabling or removing it. If you are really worried, you can also install an antivirus program on your Linux computer to make sure that no malicious software can damage your computer and data.
That’s what it looks like:
Is this article useful?
YesNohow to configure firewall in linux step by step pdf,types of firewall in linux,how to enable firewall in linux,linux firewall disable,linux kernel firewall,linux firewall settings ubuntu,how to configure iptables in linux step by step,linux network firewall