/ubuntu-security:firewall-statusfrom ubuntu-security
Probe the host firewall (ufw, with nftables/iptables/firewalld detection) on an Ubuntu desktop or server and report what is actually reachable — active or not, default policies, logging level, every rule with its number, listening services cross-checked against the rules, recent blocks, holes ufw does not see (Docker-published ports), and optionally a diff against a saved snapshot or a permissiveness review. Read-only. Use when the user says "what's the firewall state", "is ufw on", "what ports are open", "show firewall rules", "probe the firewall", "audit my ufw rules", "has the firewall changed", or before adding or removing any rule.
Ships in ubuntu-security. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Changes nothing, except writing a snapshot file when asked. Most commands need
sudo; if sudo -n true fails, ask the user to run them (or to run the session with
sudo available).
command -v ufw && sudo ufw status verbose # Ubuntu default front-end
systemctl is-active firewalld 2>/dev/null # if active, ufw should not also be
sudo nft list tables # what is really loaded in the kernel
Ubuntu ships ufw (on top of nftables via iptables-nft). Desktops have it
installed but inactive by default; cloud server images often have it inactive too
and rely on a provider firewall. If firewalld is active, report it and use
sudo firewall-cmd --list-all instead; the rest of this skill is ufw-specific.
Tables named ip filter/ip6 filter with ufw-* chains are ufw; docker, ip nat
with DOCKER chains, tailscale, libvirt / LIBVIRT_* belong to those services.
Status: inactive → nothing is filtered by ufw; say so first.
sudo ufw status verbose # active?, logging level, default in/out/routed policies
sudo ufw status numbered # rules with the numbers firewall-remove needs
sudo ufw show added # rules as the commands that created them
sudo ufw app list # app profiles (OpenSSH, CUPS, KDEConnect, ...)
Each IPv4 rule usually has a (v6) twin with its own number. Rule order matters:
ufw evaluates its rules first match wins, top to bottom.
The rule list alone doesn't say what is exposed. Cross it with what is listening:
sudo ss -tulnpH | awk '{print $1, $5, $7}' | sort -u
For each socket not bound to 127.0.0.1 / ::1 / 127.0.0.53, decide: allowed
(which rule matches its port, from where?) or blocked by the default deny.
Report it as a table:
| Port/proto | Process | Bound to | ufw | Allowed from |
|---|
systemd-resolved on 127.0.0.53:53 and 127.0.0.54:53 is local-only; skip it.
On Ubuntu 22.10+ sshd is socket-activated, so the listener shows as systemd (pid 1)
on port 22 — that is still SSH.
Use the bundled summariser (see "Scripts" below):
bash "$SCRIPTS/ufw-blocks.sh" --since "1 hour ago"
or by hand:
sudo journalctl -k --since -1h --no-pager | grep 'UFW BLOCK' \
| grep -oE 'SRC=[^ ]+|DPT=[0-9]+|PROTO=[A-Z]+' | paste - - - | sort | uniq -c | sort -rn | head -20
/var/log/ufw.log has the same lines when rsyslog is installed (readable by group
adm). Logging must be on (Logging: on (low) or higher) for any of this to appear;
if it's off, an empty result means nothing.
Name the service where the port is well known (1714–1764 KDE Connect / GSConnect, 5353 mDNS, 3702 WS-Discovery, 1900 SSDP, 137–138 NetBIOS, 22000/21027 Syncthing). Repeated blocks on a known service port from a LAN address usually mean something legitimate is being refused. High random destination ports are mostly noise (late replies to expired connections).
-p 8080:80 is
reachable from the network whatever ufw says, because the traffic is DNAT-ed
and goes through FORWARD, not INPUT. List them separately:
docker ps --format '{{.Names}}\t{{.Ports}}' | grep -E '0\.0\.0\.0|\[::\]|:::'.
The same applies to Podman/LXD/libvirt port forwards.tailscale0, wg0, zt*) are filtered by ufw like
any interface unless a rule allows in on <iface>; the overlay's own ACLs apply
on top.Default: deny (routed) matters only for VMs/containers forwarding through this host.When the user wants change tracking ("has the firewall changed?", "save the current rules"):
STATE="${CLAUDE_USER_DATA:-${XDG_DATA_HOME:-$HOME/.local/share}/claude-plugins}/ubuntu-security/ufw"
mkdir -p "$STATE"
prev="$(ls -1t "$STATE"/*.rules 2>/dev/null | head -1)" # newest saved state
[ -n "$prev" ] && diff <(sort "$prev") <(sudo ufw show added | sort) # < removed, > added
sudo ufw show added > "$STATE/snapshot-$(date +%Y-%m-%dT%H%M%S).rules"
To diff against the original instead, use the baseline-*.rules file.
baseline-*.rules is written by firewall-setup; never overwrite it. ufw show added is the best diff format: one line per rule, as the command that created it.
Only when the user asks for an audit/review of the rules. Flag, without changing anything:
Anywhere on ports that are not meant to be public;# comment;firewall-remove can clean
them up;deny/reject rule placed after an allow that already matches the same
traffic (it never fires), or an allow placed after a deny that shadows it.Lead with one line: active/inactive, default incoming policy, logging level, number of rules. Then the listening-vs-allowed table, Docker publishes if any, and the top recent blocks. Facts only. No hardening advice unless the user asks for it.
ufw-blocks.sh lives in this plugin's scripts/ directory:
SCRIPTS="${CLAUDE_PLUGIN_ROOT}/scripts". If CLAUDE_PLUGIN_ROOT is unset (skill
loaded on its own), clone the repo and use its copy:
git clone --depth 1 https://github.com/danielrosehill/Ubuntu-Security ~/.local/share/ubuntu-security-skills 2>/dev/null \
|| git -C ~/.local/share/ubuntu-security-skills pull -q
SCRIPTS=~/.local/share/ubuntu-security-skills/scripts
firewall-allow. Close something / clean up → firewall-remove.firewall-diagnose.firewall-setup.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
18 skills in this plugin
/av-installInstall and initialise malware and rootkit scanning on Ubuntu — the core set (ClamAV engine + clamd daemon + freshclam updater, ClamTk GUI on desktops, rkhunter) and, on request, the advanced layer (Lynis hardening audit, chkrootkit, AIDE file-integrity baseline, debsecan). Detects what is already installed, picks a reports folder, runs the first definitions update and baselines. Use when the user says "install antivirus", "set up clamav", "install rkhunter / lynis / aide / chkrootkit", "set up malware scanning", or when malware-scan finds no scanners installed./av-update-definitionsRefresh signature databases and data for every installed scanner on Ubuntu — freshclam (ClamAV), rkhunter --update, Lynis version check, debsecan CVE list — and report one status line per tool, without re-baselining rkhunter or AIDE. Also explains stale ClamAV signatures (freshclam service down, mirror rate-limiting). Use when the user says "update antivirus definitions", "refresh signatures", "update clamav", "is clamav up to date", or before a scan when signatures are old./complementary-pluginsList and install plugins that complement ubuntu-security: hardware-auth-keys, security-auditor, ubuntu-admin. Use on "related plugins"./fail2banInstall, configure and operate fail2ban on Ubuntu — sshd jail reading the systemd journal, ban time and retry thresholds, ignoring the LAN/VPN so the user can't ban themselves, list active jails and banned IPs, unban an address, and check whether fail2ban is the reason a client can't connect. Use when the user says "set up fail2ban", "protect ssh from brute force", "who is banned", "unban <ip>", "fail2ban banned me", or "is fail2ban working"./fingerprint-setupSet up a fingerprint reader for login, lock screen and sudo on an Ubuntu laptop or desktop — check the reader is supported by libfprint, install fprintd and libpam-fprintd, enroll fingers, enable fingerprint auth with pam-auth-update, verify, and troubleshoot unsupported or flaky readers. Use when the user says "set up the fingerprint reader", "enable fingerprint login", "fingerprint for sudo", "enroll my fingerprint", or "fingerprint reader not working"./firewall-allowAdd a scoped firewall exemption with ufw on an Ubuntu desktop or server — open a port, port range or app profile (OpenSSH, CUPS, KDE Connect, Samba, Syncthing...) to the LAN, a VPN interface, one host, or anywhere, with a comment, without duplicating existing rules, and verify it actually took effect. Use when the user says "open port X", "allow <service> through the firewall", "add a firewall exemption", "let my phone/printer/other machine connect", "unblock <port>", or when another skill finds ufw blocking something it needs.ubuntu-security@danielrosehill is listed by danielrosehill/claude-code-plugins — review the source before installing
npx claudepluginhub danielrosehill/claude-code-plugins --plugin ubuntu-security