Ubuntu Firewall Using UFW

It turns out that I have either been doing things the hard way, or not doing them at all in the past when it comes to firewalls on Ubuntu.  Using Uncomplicated Firewall (UFW) makes it pretty easy.

To set up a system to only allow TCP communication over some port, in this case 14300, is as easy as this:

sudo apt-get install ufw
sudo ufw allow 14300/tcp
sudo ufw logging on
sudo ufw enable
sudo ufw status

That should report something like the following when running the ‘sudo ufw status’ command:

Status: active
To Action From
-- ------ ----
14300/tcp ALLOW Anywhere
14300/tcp (v6) ALLOW Anywhere (v6)

This should maintain settings between reboots — at least it does in Ubuntu 14.04.  Reboot and run ‘sudo ufw status’ to check and make sure.

There is more information about this at https://wiki.ubuntu.com/UncomplicatedFirewall