ufw

Collection: community.general

Full Name: parallax.community.general.ufw

Aliases: community.general.ufw, ufw

Synopsis

Manage ufw firewall rules and its default policy

Parameters

NameTypeRequiredDefaultDescription
rulestringallowFirewall rule action (allow, deny, reject, limit)
portstringPort number or range to apply rule to
protostringanyProtocol for the rule (tcp, udp, any)
statestringState of UFW (enabled, disabled, reloaded, reset)
directionstringDirection of traffic (in, out, incoming, outgoing, routed)
from_ipstringanySource IP address
to_ipstringanyDestination IP address
deleteboolfalseDelete the rule instead of adding it
routeboolfalseApply rule to routed/forwarded packets
logboolfalseLog packets matching the rule
commentstringComment for the rule
interface_namestringNetwork interface name for the rule

Example

- name: Allow SSH from the management network
  ufw:
    rule: allow
    port: "22"
    proto: tcp
    from_ip: 10.0.0.0/24
    comment: management access