TL;DR
To allow all destinations with UFW, you generally don’t need a specific rule. UFW allows outgoing connections by default. However, if you have restrictive rules in place, or want to explicitly permit everything, use sudo ufw allow out.
Understanding the Problem
UFW (Uncomplicated Firewall) is a user-friendly interface for managing iptables on Linux systems. By default, UFW allows all outgoing connections and blocks all incoming connections. The ‘destination any’ concept isn’t directly configured in UFW; it’s more about what happens when you *don’t* restrict destinations.
Solution Steps
- Check Default Policies: First, confirm your current UFW policies.
sudo ufw status verboseLook for the ‘Default incoming policy’ and ‘Default outgoing policy’. If the outgoing policy is ‘allow’, you likely don’t need to do anything further.
- Allow All Outgoing Connections (if needed): If your default outgoing policy is set to ‘deny’, or if you have rules blocking specific traffic, explicitly allow all outgoing connections.
sudo ufw allow outThis command adds a rule that permits all outbound traffic regardless of destination.
- Verify the Rule: Check your UFW status again to confirm the new rule is in place.
sudo ufw status verboseYou should see an ‘ALLOW OUT’ rule listed. The output will show something similar to:
To Action From -- ------ ---- Anywhere ALLOW Anywhere (out) - Specific Destination Rules (if needed): If you only want to allow connections to *specific* destinations, use more targeted rules. For example, to allow outgoing traffic to a specific IP address:
sudo ufw allow out from any to 192.168.1.100Or to allow outgoing traffic on a specific port to a specific IP address:
sudo ufw allow out to 192.168.1.100 port 80 - Reload UFW (if necessary): In some cases, you might need to reload UFW for the changes to take effect.
sudo ufw reloadThis restarts the firewall service.
Important Considerations
- Security Implications: Allowing all outgoing connections can reduce your cyber security. It’s generally best to only allow traffic to destinations you explicitly trust.
- Incoming Connections: Remember that UFW blocks incoming connections by default. If you need to allow specific incoming services, you’ll need to create separate rules for those (e.g.,
sudo ufw allow in port 22for SSH).

