Skip to content

@aibulat/ctl-ufw

Configure ufw from a JSON list of ports: allow each one, set the default policy to deny, then enable the firewall.

Written with zx, but the published bin runs under plain node and imports zx/globals itself.

WARNING

This closes every inbound port you did not list. Run it over a console you will not lose if SSH is cut off, and make sure your SSH port is in the file.

Install

bash
sudo npm i -g @aibulat/ctl-ufw

Input file

A JSON array of ports to allow:

json
[22, 443, 8080]

Run

bash
sudo ctl-ufw fw.json

It must run as root and refuses otherwise. In order, it:

  1. reads and validates the port list,
  2. runs ufw allow <port> for each entry,
  3. runs ufw default deny,
  4. runs ufw enable,
  5. prints ufw version and ufw status.

Released under the MIT License.