Information
The default policy for outgoing traffic determines if applications and services running on your server can initiate connections to external networks without requiring specific UFW rules.
With a default deny outgoing policy the firewall will deny ALL outgoing traffic and is a highly restrictive policy that requires the addition of specific allow rules.
Solution
Run the following command to set the default for outgoing to deny :
# ufw default deny outgoing
Warning: Any port or protocol without a explicit allow before the default deny will be blocked.
Impact:
Any port and protocol not explicitly allowed will be blocked. The following rules are an example of some outgoing allow rules that should be considered before applying this default deny.
ufw allow out http
ufw allow out https
ufw allow out ntp # Network Time Protocol
ufw allow out to any port 53 # DNS
ufw allow out to any port 853 # DNS over TLS
ufw logging on