Import firewall role from network repo

Move, actually.
This commit is contained in:
Timotej Lazar 2026-02-23 09:56:33 +01:00
parent 88061d97b2
commit 754c3da31f
21 changed files with 801 additions and 1 deletions

View file

@ -0,0 +1,2 @@
# The init script for conntrackd wants this, not sure about conntrackd itself.
net.netfilter.nf_conntrack_tcp_be_liberal = 1

View file

@ -0,0 +1,15 @@
# This is used by sshd in default VRF to receive configuration updates. Lock
# down to only allow executing the update script.
# Only allow pubkey auth.
KbdInteractiveAuthentication no
PasswordAuthentication no
PermitRootLogin prohibit-password
# Disable what we can.
AllowTcpForwarding no
GatewayPorts no
X11Forwarding no
# And then disable everything else.
ForceCommand /usr/local/bin/update

View file

@ -0,0 +1,41 @@
#!/bin/sh
set -e
apply() {
cp -R /opt/config/etc/nftables.d /etc || return 1
ip vrf exec mgmt nft -I /etc/nftables.d -f /etc/nftables.nft || return 2
cp -R /opt/config/etc/wireguard /etc || return 3
wg syncconf wg /etc/wireguard/wg.conf || return 4
}
cleanup() {
rm -fr /opt/config
}
message() {
logger "${@}"
echo "${@}"
}
# clean now and on exit
cleanup
trap cleanup EXIT
mkdir -p /opt/config
tar xz -C /opt/config --warning=no-timestamp
current="$(cat /opt/version 2>/dev/null || echo -1)"
next="$(cat /opt/config/version 2>/dev/null || echo -1)"
message "Updating config from v${current} to v${next}"
if [ "${next:-0}" -ne "${current:-0}" ] ; then
message "Applying config v${next}"
if apply ; then
echo "${next}" > /opt/version
message "Applied config v${next}"
else
error="$?"
message "Could not apply config v${next}, error ${error}"
exit "${error}"
fi
fi