ufw-prepend
Add an Uncomplicated Firewall rule ahead of existing rules
TLDR
SYNOPSIS
ufw [--dry-run] prepend allow|deny|reject|limit [rule]ufw [--dry-run] route prepend allow|deny|reject|limit [rule]
DESCRIPTION
ufw prepend adds a rule at the front of the matching ruleset. It is a ufw subcommand, not a separate binary.Unlike ufw insert, prepend does not take a position. An IPv4 rule is placed before every other IPv4 rule. An IPv6 rule is placed before every other IPv6 rule. That is the form used by dynamic firewalls and intrusion-prevention hooks, which must push a block ahead of rules already loaded without looking up a number.The rule body is the same syntax as ufw allow, ufw deny, ufw reject, and ufw limit, including the full from / to / port / proto form. ufw route prepend targets traffic forwarded through the host rather than traffic destined to it.
PARAMETERS
prepend
Insert the rule before every existing user rule of the same IP version. No rule number is requiredroute prepend
Same placement for a forwarded ruleallow / deny / reject / limit
Action of the new rule. The rest of the line is normal ufw rule syntaxcomment 'text'
Attach a comment to the new rule. prepend cannot change the comment on a rule that already exists--dry-run
Show what would change without applying it
INSTALL
CAVEATS
Requires root or sudo. A broad prepended allow can shadow a later, more specific deny, because the first match wins. A prepended deny of the current SSH source can lock you out. Prefer --dry-run.IPv4 and IPv6 lists are ordered separately, so the new rule is not always number 1 in the combined `ufw status numbered` listing.
HISTORY
Part of ufw (Uncomplicated Firewall), the Ubuntu-originated frontend for iptables and nftables.
SEE ALSO
ufw(8), ufw-insert(8), ufw-delete(8), ufw-status(8), ufw-allow(8), ufw-deny(8), ufw-route(8)
