ufw-route
Manage Uncomplicated Firewall rules for forwarded traffic
TLDR
SYNOPSIS
ufw [--dry-run] route [delete] [insert NUM] [prepend] allow|deny|reject|limit [rule]
DESCRIPTION
ufw route manages rules for packets routed through the host. It is a ufw subcommand, not a separate binary.Ordinary allow and deny rules apply when this machine is an endpoint. A route rule applies when the packet should leave toward another host. `ufw route allow in on eth0 out on eth1 to 12.34.45.67 port 80 proto tcp` accepts packets that arrive on eth0 and are forwarded out eth1 to TCP port 80 on that address.In `ufw status`, forwarded rules are marked ALLOW FWD (or the matching deny, reject, or limit action). Input and output rules print the interface relative to this host as an endpoint. Route rules print it relative to the direction packets flow through the firewall.The default policy for routed traffic is deny. A route rule does not turn forwarding on. Enable IPv4 forwarding and IPv6 forwarding for `default` and `all` in `/etc/ufw/sysctl.conf`, then run `ufw disable` and `ufw enable` so ufw reloads those settings. Another sysctl configuration can override that file. See sysctl.
PARAMETERS
route
Match traffic forwarded through this host, not traffic destined to the hostallow / deny / reject / limit
Action for matching forwarded packetsin on interface
Interface the forwarded packet arrives onout on interface
Interface the forwarded packet leaves onfrom address / to address
Source and destination. to is often a host behind the firewall, not this machineport port / proto protocol
Destination port and protocol, as in other ufw rules. An application profile uses app in place of portinsert NUM
Place the route rule at that 1-based positionprepend
Place the route rule ahead of other route rules of the same IP versiondelete
Remove the route rule given in the rest of the command. Numbered removal is `ufw delete NUM` after `ufw status numbered`comment 'text'
Attach a comment to the rule--dry-run
Show what would change without applying it
INSTALL
CAVEATS
Requires root or sudo. Turning on forwarding makes the host a router. Keep the default routed policy at deny unless every forwarded flow is intentional.Route syntax is not OpenBSD PF syntax. Interfaces are written in on and out on, matching netfilter's FORWARD chain.Deleting by number removes one numbered row. When IPv6 is enabled, prefixing the original rule with route delete is the form that drops the rule as specified rather than a single numbered row.
HISTORY
Part of ufw (Uncomplicated Firewall), the Ubuntu-originated frontend for iptables and nftables.
SEE ALSO
ufw(8), ufw-allow(8), ufw-default(8), ufw-delete(8), ufw-insert(8), ufw-prepend(8), sysctl(8), iptables(8)
