shellcheck / shellcheck (push) Failing after 19s
60-security.sh now checks network exposure (step 4), from two other machines made of network namespaces in the VM: one on private addresses, like a neighbour on the same Wi-Fi, and one on public-looking ones. From each, over IPv4 and IPv6: only SSH and LocalSend are open, a container's published port can't be reached, containers still reach both machines, and SSH takes keys only. It also checks ufw's rules and sshd -T. It found that ufw-docker's rules let any private address (10/8, 172.16/12, 192.168/16) reach published ports, so anyone on a café's or hotel's Wi-Fi could. system/docker-firewall.sh lets only Docker's own bridges (docker0, br-+) past instead; firewall.sh runs it on a new install and migration 1794878760 on existing machines. To let other machines reach a container's port: sudo ufw-docker allow <container> <port>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Purpose : Turn on the ufw firewall. Incoming connections are blocked except
|
|
# for the services CoreDesktop runs, and ufw-docker stops ports
|
|
# published by Docker containers from getting around the firewall.
|
|
|
|
set -e
|
|
|
|
source "$HOME/.local/share/coredesktop/utils.sh"
|
|
|
|
install_packages ufw ufw-docker
|
|
|
|
sudo ufw default deny incoming
|
|
sudo ufw default allow outgoing
|
|
|
|
sudo ufw allow 22/tcp comment 'SSH'
|
|
sudo ufw allow 5353/udp comment 'mDNS'
|
|
sudo ufw allow 53317 comment 'LocalSend'
|
|
sudo ufw allow in on tailscale0 comment 'Tailscale'
|
|
|
|
sudo ufw --force enable
|
|
sudo systemctl enable ufw.service
|
|
|
|
# ufw-docker only installs its rules while ufw is active, and they take effect
|
|
# once ufw restarts
|
|
if ! sudo grep -q 'BEGIN UFW AND DOCKER' /etc/ufw/after.rules; then
|
|
sudo ufw-docker install
|
|
sudo systemctl restart ufw.service
|
|
fi
|
|
|
|
# ufw-docker lets private addresses, the rest of a café's Wi-Fi say, reach
|
|
# published ports; only Docker's own bridges, from here on
|
|
bash "$HOME/.local/share/coredesktop/system/docker-firewall.sh"
|
|
|
|
sudo ufw status verbose
|