Interactive nftables firewall builder with a terminal UI and safety rollback.
RuleSmith lets you build, test, and apply nftables firewall rules without hand-writing configuration files. It provides a live preview, packet simulator, preset rulesets, and a 30-second safety rollback to prevent lockouts.
- Interactive TUI — navigate rules with arrow keys, add/edit/delete via menus
- Packet Simulator — test which rule catches a hypothetical packet before applying
- Diff View — compare current live ruleset against pending changes
- Preset Rulesets — one-key load for webserver, paranoid, and homelab profiles
- Safety Rollback — after applying rules, a 30-second timer starts; press
yto keep or wait for auto-revert - Backup History — automatic backups before every apply, with restore support
- CLI Mode — non-interactive commands for scripts and automation
- Linux with nftables
- Rust toolchain (for building from source)
git clone https://github.com/Kolgrim33/rulesmith.git cd rulesmith cargo build --release Usage TUI (Interactive) bash sudo ./target/release/rulesmith Without sudo it runs in read-only mode: you can view rules and simulate packets, but cannot edit or apply. CLI (Non-interactive) bash # Show current ruleset sudo ./target/release/rulesmith show # Export to file sudo ./target/release/rulesmith export /tmp/myrules.nft # Apply a ruleset file directly sudo ./target/release/rulesmith apply /tmp/myrules.nft # Apply without safety timer (dangerous) sudo ./target/release/rulesmith apply /tmp/myrules.nft --force # List backups ./target/release/rulesmith list-backups # Restore a backup sudo ./target/release/rulesmith restore <backup-id> TUI Key Reference Dashboard Table Key Action q Quit ? Show help a Add new rule (opens editor) d Delete selected rule Shift + Up/Down Move rule up/down t Packet simulator D Diff view A Apply ruleset p Show preset menu, then 1/2/3 to load b Backup history r Refresh ruleset from system Up/Down Navigate rules Left/Right Navigate tables/chains Rule Editor Table Key Action Up/Down Navigate fields Enter Edit selected field Space Cycle preset values (family, protocol, action, direction) s Save rule and return to dashboard Esc Cancel and return While editing a field: Type normally Enter to confirm Esc to cancel Backspace to delete Applying Rules Press A on the dashboard Press Enter to confirm Rules are pushed to the kernel A 30-second timer starts; status bar shows ROLLBACK 27s Press y to confirm permanently If you do not confirm in 30 seconds, rules auto-revert to the last backup Packet Simulator Table Key Action r Run simulation e Edit packet fields Esc Back to dashboard Presets Table Key Name Description 1 webserver Allow SSH(22), HTTP(80), HTTPS(443); drop rest 2 paranoid Only SSH from LAN; drop everything else 3 homelab Allow LAN range, SSH, DNS, HTTPS; drop rest Safety Tips Always test in a VM or secondary machine first The 30-second rollback prevents most lockouts, but if you break local loopback (lo) rules you may still lose local connectivity Backups are stored in ~/.local/share/rulesmith/backups/ Read-only mode is automatically enabled when not running as root License MIT