Set default firewall policy to drop in Ubuntu 18.04 – UFW

The default package for firewall in Ubuntu 18.04 is ‘UFW’. This article explains how to set default firewall policy to drop in Ubuntu 18.04 using UFW.

Enable firewall in Ubuntu if its not enabled

[email protected]~# sudo ufw enable

For set default firewall policy to drop or block in your Ubuntu server 18.04. Run the below command

[email protected]~# sudo ufw default deny incoming

Run below command to make the default firewall policy to allow all outgoing connections in your ubuntu server 18.04.

[email protected]~# sudo ufw default allow outgoing

Finaly reload firewall to take effect the newly applied policies

[email protected]~# sudo ufw reload

Now you must open each and every ports/services which need to allow incoming connections.

Leave a Reply

Are you a human being ? *