To install a firewall on a Linux server, you can use the ufw (Uncomplicated Firewall) command line utility. Here are the steps to follow:
- Before you start, make sure that you are logged in as a user with
sudoprivileges. - To check if
ufwis installed on your system, run the following command:
sudo ufw status
If ufw is not installed, you can install it with the following command:
sudo apt-get update
sudo apt-get install ufw
- Once
ufwis installed, you can enable it with the following command:
sudo ufw enable
- By default,
ufwwill allow all outgoing connections and block all incoming connections. If you want to allow incoming connections, you can use theufw allowcommand to specify the ports or services that you want to allow. For example, to allow incoming SSH connections, you can use the following command:
sudo ufw allow ssh
- You can also use the
ufw denycommand to block incoming connections on specific ports or services. For example, to block incoming HTTP connections, you can use the following command:
sudo ufw deny http
- After making any changes to the firewall rules, you can use the
ufw statuscommand to check the status of the firewall and see a list of the allowed and denied connections.
