A solution is to use UFW in order to manage your iptables rules.
UFW, or Uncomplicated Firewall, is an interface to iptables that is geared towards simplifying the process of configuring a firewall. While iptables is a solid and flexible tool, it can be difficult for beginners to learn how to use it to properly configure a firewall. If you’re looking to get started securing your network, and you’re not sure which tool to use, UFW may be the right choice for you.
To enable UFW, use this command:
sudo ufw enable
You will receive a warning that says the command may disrupt existing SSH connections. We already set up a firewall rule that allows SSH connections, so it should be fine to continue. Respond to the prompt with
y and hit
The firewall is now active. Run the
sudo ufw status verbose command to see the rules that are set. The rest of this tutorial covers how to use UFW in more detail, like allowing or denying different kinds of connections.
HTTPS on port 443, which is what encrypted web servers use, using
sudo ufw allow https or
sudo ufw allow 443
You can also check our full tutorial on how to setup a firewall with UFW on Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04
Hope that this helps!
UFW, or Uncomplicated Firewall, is an interface to iptables that is geared towards simplifying the process of configuring a firewall on Linux servers. In this guide, you'll learn how to set up a firewall with UFW on Ubuntu 18.04.