To set up a UFW firewall on Ubuntu 16.04 LTS server, follow these steps:
- Install UFW: UFW (Uncomplicated Firewall) is not installed by default on Ubuntu 16.04. You can install it using the following command:
sudo apt-get update
sudo apt-get install ufw
- Enable the firewall: After installation, enable the firewall by running the following command:
sudo ufw enable
- Allow incoming traffic: By default, UFW blocks all incoming traffic. To allow incoming traffic, you need to create rules to allow specific ports or services. For example, to allow incoming SSH traffic, run the following command:
sudo ufw allow ssh
- Allow outgoing traffic: By default, UFW allows all outgoing traffic. However, you can create rules to block specific services or ports.
- Verify the firewall rules: You can verify the firewall rules using the following command:
sudo ufw status
This command will show you the status of the firewall, including the rules that have been added and their status.
That’s it! You have now set up a UFW firewall on your Ubuntu 16.04 LTS server. You can modify or add rules as needed to secure your server.