How to set up a UFW firewall on Ubuntu 16.04 LTS serverTo set up a UFW firewall on an Ubuntu 16.04 LTS server, follow these steps:
- Install UFW:
reot ref:lautturi.comsudo apt-get update
sudo apt-get install ufw
- Check the status of UFW:
sudo ufw status
- By default, UFW is disabled. To enable it, run:
sudo ufw enable
- Allow SSH connections:
sudo ufw allow ssh
- Allow HTTP and HTTPS traffic:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
- If you want to allow other services, such as FTP or SMTP, you can use the same syntax as above, replacing the port number and protocol with the appropriate values. For example, to allow FTP connections on port 21, you would run:
sudo ufw allow 21/tcp
- You can also specify a specific IP address or range of IP addresses to allow or deny access. For example, to allow access from a specific IP address, you would run:
sudo ufw allow from 123.456.789.0/24
- To deny access from a specific IP address or range of IP addresses, you can use the deny command. For example:
sudo ufw deny from 123.456.789.0/24
- Once you have finished adding rules, you can check the status of your firewall with:
sudo ufw status verbose
This will show you a list of the rules that are currently in place.
- If you want to delete a rule, you can use the delete command. For example, to delete the rule that allows SSH connections, you would run:
sudo ufw delete allow ssh