How to Stop the Ubuntu ‘Ufw’ Firewall from Blocking Local Traffic

The Internal Network Blockade

UFW (Uncomplicated Firewall) is the default, highly effective firewall configuration tool in Ubuntu. When you enable UFW on a new server, it usually defaults to a “deny all incoming, allow all outgoing” policy. This is perfect for securing a web server against the public internet.

However, if you are running a server inside a trusted local area network (LAN)—such as a home media server, a local database node, or a Docker host—this strict default policy will immediately block you from accessing your own services from another computer in your house or office (e.g., blocking access to a local Plex server or a Samba file share). Instead of turning the firewall off completely, you should simply configure UFW to automatically trust all traffic originating from your safe local network.

How to Allow Local Network Traffic in UFW

You can instruct UFW to allow all connections coming from your specific local IP subnet.

  1. Open your Ubuntu Terminal (or connect via SSH).
  2. First, you need to determine what your local subnet is. Run the following command:
ip route | grep src

Look for a line that starts with something like 192.168.1.0/24 or 10.0.0.0/24. This is your local subnet.

  1. Now, tell UFW to allow all incoming traffic from that entire subnet. Use the subnet you found in the previous step. For example, if your subnet is 192.168.1.0/24, run:
sudo ufw allow from 192.168.1.0/24
  1. UFW will confirm that the rule has been added. You can verify the new rule by checking the firewall status:
sudo ufw status

Your Ubuntu server is now perfectly secure from outside internet threats, but it will seamlessly allow all local devices (like your laptop, smart TV, or other servers on the same switch) to communicate with it without restriction.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.