#!/usr/bin/env bash # bootstrap-unbound.sh # One-shot installer / hardener for an Unbound recursive resolver # Tested on Debian 11+/Ubuntu 22.04+ (systemd-based) set -euo pipefail IFS=$'\n\t' ######################### 1. Settings ################################ # Where you’ll listen for queries (adjust subnet as needed!) LISTEN_SUBNET="192.168.0.0/16" THREADS="$(nproc)" ROOT_HINTS="/var/lib/unbound/root.hints" UNBOUND_CONF="/etc/unbound/unbound.conf" ######################### 2. Install ################################# echo "πŸ“¦ Installing Unbound..." apt-get update -qq DEBIAN_FRONTEND=noninteractive apt-get install -y unbound curl jq dnsutils ######################### 3. Root hints ############################## echo "🌍 Fetching ICANN root hints..." curl -sSL https://www.internic.net/domain/named.root -o "$ROOT_HINTS" ######################### 4. Config file ############################# echo "πŸ›  Writing $UNBOUND_CONF ..." cat > "$UNBOUND_CONF" <