feat(dns): 'hosts' output + /etc/hosts simulation docs

dns-records.sh <mode> hosts prints a marker-wrapped /etc/hosts block to pipe
into /etc/hosts (single-machine testing without a DNS server). README documents
apply/remove + the airgap caveat (spoof hosts break real internet while present).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-24 14:23:14 +02:00
parent d8aefe95c4
commit c279f35e14
2 changed files with 35 additions and 1 deletions

View File

@@ -40,9 +40,21 @@ names=("${services[@]}")
case "$mode" in
online) ;;
airgap) names+=("${spoof[@]}") ;;
*) echo "usage: $0 [online|airgap]" >&2; exit 1 ;;
*) echo "usage: $0 [online|airgap] [hosts]" >&2; exit 1 ;;
esac
# Marker so /etc/hosts edits can be applied/removed cleanly.
MARK="ulicraft ${mode}"
# `hosts` format: print ONLY the /etc/hosts block (marker-wrapped) so it can be
# piped straight into /etc/hosts to simulate the party DNS. See README.
if [ "${2:-}" = hosts ]; then
echo "# >>> ${MARK} >>>"
for n in "${names[@]}"; do printf '%s %s\n' "$HOST_LAN_IP" "$n"; done
echo "# <<< ${MARK} <<<"
exit 0
fi
echo "# DNS records for mode=${mode} -> ${HOST_LAN_IP}"
echo "# Configure these on your party DNS server (all A records to the host)."
echo