ufw-deny
Block traffic through Uncomplicated Firewall
TLDR
SYNOPSIS
ufw [--dry-run] deny [rule]
DESCRIPTION
ufw deny adds a deny rule to Uncomplicated Firewall so matching packets are dropped (similar to iptables DROP). Rules can be simple port denials (`ufw deny 23/tcp`), source or network blocks (`ufw deny from 203.0.113.0/24`), or full five-tuple style rules with source, destination, port, protocol, and interface.Deny rules are useful for blocking known bad hosts, unused services, or entire subnets while keeping a default allow policy elsewhere. Prefer deny when you want silent drops; use reject (via `ufw reject`) when you want the peer to receive an explicit refusal. Use `ufw status numbered` to list rules and `ufw delete` to remove them by number.
PARAMETERS
deny
Drop matching traffic (inserts a deny/DROP rule)port[/protocol]
Simple form: port number, optional /tcp or /udpfrom address
Match source address or network (CIDR)to address
Match destination addressport port
Destination port (or range) when using full rule syntaxproto protocol
Protocol: tcp, udp, igmp, gre, etc.in / out
Direction of trafficon interface
Limit rule to a network interfacecomment 'text'
Attach a human-readable comment to the rule--dry-run
Show what would change without applying it
INSTALL
CAVEATS
Requires root or sudo. Rule order matters when combined with allows — more specific rules should be ordered carefully (`ufw insert`). A deny rule does not override a more specific earlier allow if packet matching selects the allow first. Application profile names must match installed profiles under `/etc/ufw/applications.d/`. Blocking yourself from SSH while managing a remote host can lock you out; prefer `--dry-run` and ensure alternate access first.
HISTORY
Part of ufw (Uncomplicated Firewall), the Ubuntu-originated frontend for iptables/nftables.
SEE ALSO
ufw(8), ufw-allow(8), ufw-enable(8), ufw-disable(8), iptables(8), nftables(8)