added ufw script for shared connections

This commit is contained in:
z0rc 2024-09-11 10:02:32 +00:00
parent 3d09d50d6f
commit 551efa0e13

19
ufw_shared_ipv4.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -eEuxo pipefail
if (( ${#} != 1 )); then
echo "Usage: $(basename "${BASH_SOURCE[0]}") INTERFACE" >&2
exit 1
fi
interface="${1}"
any_ipv4="0.0.0.0/0"
subnet="10.42.0.0/24"
gateway="10.42.0.1"
ufw allow in on "${interface}" from "${any_ipv4}" port bootpc to "${any_ipv4}" port bootps
ufw allow in on "${interface}" from "${subnet}" to "${gateway}" port domain
ufw route allow in on "${interface}" from "${subnet}" to "${any_ipv4}"