/ubuntu-security:firewall-diagnosefrom ubuntu-security
Work out whether the host firewall (ufw) is what is blocking a connection on an Ubuntu desktop or server, and if so which rule or policy — reads UFW BLOCK lines from the kernel log (journalctl -k) and /var/log/ufw.log, checks logging is on, walks first-match rule order, interface and address-family mismatches, services bound to localhost, and Docker-published ports that bypass ufw. Diagnoses only; hands the fix to firewall-allow / firewall-remove. Use when the user asks "is the firewall blocking X?", "why can't my phone / other machine connect to this one", "KDE Connect / Samba / printer / SSH doesn't work", "port X is unreachable", "ufw is blocking something", or "I opened the port but it still doesn't work".
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.
Goal: a yes/no with evidence, then the smallest fix. Diagnose before changing anything; temporarily disabling ufw "to test" is a last resort and only with the user's agreement (never on a remote box without an out-of-band console).
Gather first: which service/port, which client (IP, on LAN / VPN / internet), direction (into this machine, or out from it).
sudo ufw status verbose | head -5
Status: inactive → ufw is not the cause. Look elsewhere (service down, bound to
localhost, router/cloud firewall, client side).Logging: off → blocks are invisible. Turn on low logging (it records blocked
packets only, rate-limited) and reproduce:
sudo ufw logging low. Tell the user you did; offer to turn it back off after.sudo ss -tulnp | grep -E ':<port>\b'
127.0.0.1 / ::1 only → not a firewall problem; the service's own config
must listen on the LAN address (e.g. bind-address, listen_addresses,
ListenAddress).ssh.socket
(systemctl edit ssh.socket → ListenStream=), not just sshd_config.Reproduce the failing connection from the client, then:
bash "$SCRIPTS/ufw-blocks.sh" --since "10 min ago" --port <port>
bash "$SCRIPTS/ufw-blocks.sh" --since "10 min ago" --src <client-ip> --raw | tail
Without the script:
sudo journalctl -k --since "-10min" --no-pager | grep -E 'UFW (BLOCK|AUDIT)' | grep -E "DPT=<port>|SRC=<client-ip>"
sudo grep -E "DPT=<port>" /var/log/ufw.log | tail # needs rsyslog; group adm can read it
Reading a line: [UFW BLOCK] IN=<iface> OUT= ... SRC=<client> DST=<this host> PROTO=TCP SPT=<client port> DPT=<service port>. IN= set and OUT= empty = inbound
to this host. OUT= set = outbound from this host (only blocked if the outgoing
policy is deny or a deny-out rule matches). IN= and OUT= both set = routed /
forwarded traffic (VMs, containers) → governed by ufw route rules and
Default: ... (routed).
sudo tcpdump -ni any port <port> while the client retries).DST= a broadcast/multicast address; allowing the
unicast port alone won't fix discovery.sudo ufw status numbered
Walk the list top to bottom for the packet you saw (interface, source, protocol, port). ufw is first match wins:
deny (incoming) drops it. Fix with
firewall-allow.insert the allow above it, or remove the deny (firewall-remove).on tailscale0 / on eth0 but the log shows
IN=wlp3s0 (or the reverse). The client came in over a different path than
assumed (e.g. LAN vs VPN, Wi-Fi vs Ethernet).192.168.1.0/24 but SRC= is outside it (another
subnet, the VPN's CGNAT range 100.64.0.0/10, a Docker bridge 172.17.0.0/16, or an
IPv6 address).SRC=fe80:... or a global v6 address); or
IPV6=no in /etc/default/ufw.proto tcp but the service also needs UDP (DNS, mDNS, KDE
Connect, Syncthing discovery, WireGuard, QUIC/HTTP3).LIMIT rule and [UFW LIMIT BLOCK] lines: the client opened more
than 6 connections in 30 s.docker ps shows 0.0.0.0:8080->80/tcp) bypass ufw:
if a container port is reachable despite a deny, or a ufw allow seems to "do
nothing" for it, that is why. Traffic from containers to the host (e.g. a
container reaching a host service) comes in on docker0/br-* and is filtered by
ufw INPUT — allow it with allow in on docker0 ... or from the bridge subnet.firewalld, a hand-written nftables ruleset
(sudo nft list ruleset), cloud provider security groups, the router.State: blocked by ufw yes/no, the evidence (one or two log lines, the rule number),
and the fix as a one-liner. If the user asked for it to work, apply the fix via the
firewall-allow / firewall-remove procedure and re-test (step 3 should show no
new blocks). If you turned logging on only for this, offer to set it back:
sudo ufw logging off.
ufw-blocks.sh is in this plugin's scripts/ directory:
SCRIPTS="${CLAUDE_PLUGIN_ROOT}/scripts". If CLAUDE_PLUGIN_ROOT is unset, clone
https://github.com/danielrosehill/Ubuntu-Security (e.g. to
~/.local/share/ubuntu-security-skills) and use its scripts/.
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