confpub/ufw_shared_ipv4.sh

20 lines
455 B
Bash
Executable File

#!/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}"