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
sudo
privileges. - To check if
ufw
is 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
ufw
is installed, you can enable it with the following command:
sudo ufw enable
- By default,
ufw
will allow all outgoing connections and block all incoming connections. If you want to allow incoming connections, you can use theufw allow
command 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 deny
command 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 status
command to check the status of the firewall and see a list of the allowed and denied connections.