All tools
ChainToolsFirewall rules Protect

UFW Parser

Collect UFW firewall rules from your servers and export them as tables, CSV, Excel or Ansible YAML

View on GitHub
Best forfirewall audits and Ansible adoption

Overview

UFW Parser fetches and parses UFW firewall rules from Linux servers — locally or remotely over SSH — and presents them in a clean, tabular, exportable format.

It is built for reviewing and documenting firewall configuration across a fleet: rules are grouped per server and can be exported straight to Ansible host_vars YAML to bring existing servers under configuration management.

Rules are read from the same lines UFW rebuilds its own rule list from, so allow, deny, reject and limit rules, IPv6 addresses, port ranges and routed rules all come through as UFW stores them.

Key Features

  • Local or remote — Read UFW rules from local copies or over SSH with sudo, including SSH agent support. Host keys are checked against known_hosts.
  • Every rule type — Allow, deny, reject and limit rules, logging, incoming, outgoing and routed rules, port lists and ranges, IPv4 and IPv6 addresses with prefix length.
  • Per-server grouping — Groups and consolidates firewall rules per server; servers are read in parallel.
  • Multiple export formats — Terminal table, CSV, Excel, or Ansible host_vars YAML with community.general.ufw parameters.
  • Ready for scripts — Exit codes report servers that could not be read and skipped rules; failures are listed at the end of the run.
  • Structured logs — Logging with file rotation, plus a debug mode.
  • Modular design — CLI-driven and easy to extend.

Installation

Requirements

  • Python 3.10 or newer
  • For remote servers: SSH access with the host key in known_hosts, and sudo without a password for reading the rule files
git clone https://github.com/qf3l3k/ufw_parser.git
cd ufw_parser
pip install .

Configuration

Copy examples/hosts.example.yml to ~/.config/ufw_parser/hosts.yml and list the servers and how to reach them:

servers:
  web-01:
    hostname: web-01.example.com
    processing: local
    rule_path: /path/to/backup/web-01.example.com/etc/ufw
  db-01:
    hostname: db-01.example.com
    processing: remote
    ssh_user: admin
    use_ssh_agent: true
    rule_path: /etc/ufw

Usage

ufw_parser -c ~/.config/ufw_parser/hosts.yml -o ansible_yaml -of ~/exports/
OptionDescription
-c, --configPath to the hosts configuration file (default ~/.config/ufw_parser/hosts.yml)
-o, --outputOutput format: screen (default), csv, excel or ansible_yaml
-of, --output_folderDestination folder for exports (default ~/.config/ufw_parser/)
-l, --logLog files directory (default ~/.config/ufw_parser/)
-j, --jobsNumber of servers read in parallel (default 8)
--ssh-timeoutSeconds for SSH connect, login and each remote command (default 15)
-d, --debugEnable debug logging
-v, --versionShow the version

Related Resources

Need something custom?

We build tooling and automation for node operators and chain teams, and can help you deploy or adapt this tool to your setup.