11#! /bin/bash
22
33# Debian and Ubuntu Server Hardening Interactive Script
4- # Version: 0.81.0 | 2026-06-21
4+ # Version: 0.81.1 | 2026-07-05
55# Changelog:
6+ # - v0.81.1: Fix IPv6 connectivity issues with Secure DNS.
7+ # Implement Docker-compatible IPv6 SLAAC sysctl configuration and enable native IPv6 networking in Docker daemon.
68# - v0.81.0: Added optional encrypted DNS (DoT) setup using Quad9 and Cloudflare.
79# Includes automatic installation of systemd-resolved if needed and configuration to block tracking protocols.
810# - v0.80.8: Tested and verified compatibility with Ubuntu 26.04 LTS.
114116set -euo pipefail
115117
116118# --- Update Configuration ---
117- CURRENT_VERSION=" 0.81.0 "
119+ CURRENT_VERSION=" 0.81.1 "
118120SCRIPT_URL=" https://raw.githubusercontent.com/buildplan/du_setup/refs/heads/main/du_setup.sh"
119121CHECKSUM_URL=" ${SCRIPT_URL} .sha256"
120122
@@ -278,7 +280,7 @@ print_header() {
278280 printf ' %s\n' " ${CYAN} ╔═════════════════════════════════════════════════════════════════╗${NC} "
279281 printf ' %s\n' " ${CYAN} ║ ║${NC} "
280282 printf ' %s\n' " ${CYAN} ║ DEBIAN/UBUNTU SERVER SETUP AND HARDENING SCRIPT ║${NC} "
281- printf ' %s\n' " ${CYAN} ║ v0.81.0 | 2026-06-21 ║${NC} "
283+ printf ' %s\n' " ${CYAN} ║ v0.81.1 | 2026-07-05 ║${NC} "
282284 printf ' %s\n' " ${CYAN} ║ ║${NC} "
283285 printf ' %s\n' " ${CYAN} ╚═════════════════════════════════════════════════════════════════╝${NC} "
284286 printf ' \n'
@@ -4451,7 +4453,7 @@ configure_secure_dns() {
44514453 print_info " Applying secure DNS settings (Quad9 with Cloudflare Fallback)..."
44524454 # Using Domains=~. forces global DNS to override DHCP interface-specific DNS safely
44534455 mkdir -p /etc/systemd/resolved.conf.d
4454- tee /etc/systemd/resolved.conf.d/99-secure-dns.conf > /dev/null << EOF
4456+ tee /etc/systemd/resolved.conf.d/99-secure-dns.conf > /dev/null << SECURE_DNS_CONFIG
44554457[Resolve]
44564458DNS=9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
44574459FallbackDNS=1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
@@ -4460,7 +4462,7 @@ DNSSEC=allow-downgrade
44604462DNSOverTLS=opportunistic
44614463MulticastDNS=no
44624464LLMNR=no
4463- EOF
4465+ SECURE_DNS_CONFIG
44644466
44654467 print_info " Enabling and restarting systemd-resolved..."
44664468 systemctl enable --now systemd-resolved
@@ -4485,10 +4487,24 @@ configure_kernel_hardening() {
44854487 return 0
44864488 fi
44874489
4490+ # Detect the main network interface
4491+ local MAIN_IFACE
4492+ MAIN_IFACE=$( ip route show default | awk ' /default/ {print $5}' | head -1)
4493+
4494+ # Fallback to IPv6 default route if IPv4 is missing
4495+ if [[ -z " $MAIN_IFACE " ]]; then
4496+ MAIN_IFACE=$( ip -6 route show default | awk ' /default/ {print $5}' | head -1)
4497+ fi
4498+
4499+ # Fallback just in case
4500+ MAIN_IFACE=${MAIN_IFACE:- eth0}
4501+
4502+ log " Detected main interface for sysctl SLAAC fix: $MAIN_IFACE "
4503+
44884504 local KERNEL_HARDENING_CONFIG
44894505 KERNEL_HARDENING_CONFIG=$( mktemp)
44904506 # create the config in a temporary file
4491- tee " $KERNEL_HARDENING_CONFIG " > /dev/null << ' EOF '
4507+ tee " $KERNEL_HARDENING_CONFIG " > /dev/null << KERNEL_HARDENING_CONFIG
44924508# Recommended Security Settings managed by du_setup.sh
44934509# For details, see: https://www.kernel.org/doc/Documentation/sysctl/
44944510
@@ -4516,6 +4532,12 @@ net.ipv6.conf.default.accept_redirects=0
45164532net.ipv6.conf.all.accept_source_route=0
45174533net.ipv6.conf.default.accept_source_route=0
45184534
4535+ # --- IPv6 SLAAC Fix for Docker ---
4536+ # Allow IPv6 SLAAC to function while Docker forwarding is enabled
4537+ net.ipv6.conf.all.accept_ra=2
4538+ net.ipv6.conf.default.accept_ra=2
4539+ net.ipv6.conf.${MAIN_IFACE} .accept_ra=2
4540+
45194541# --- Kernel Security ---
45204542# Enable ASLR (Address Space Layout Randomization) for better security
45214543kernel.randomize_va_space=2
@@ -4530,7 +4552,7 @@ kernel.yama.ptrace_scope=1
45304552# Protect against TOCTOU (Time-of-Check to Time-of-Use) race conditions
45314553fs.protected_hardlinks=1
45324554fs.protected_symlinks=1
4533- EOF
4555+ KERNEL_HARDENING_CONFIG
45344556
45354557 local SYSCTL_CONF_FILE=" /etc/sysctl.d/99-du-hardening.conf"
45364558
@@ -4601,15 +4623,23 @@ install_docker() {
46014623 "compress": "true"
46024624 },
46034625 "live-restore": true,
4626+ "ipv6": true,
4627+ "ip6tables": true,
4628+ "experimental": true,
46044629 "dns": [
46054630 "9.9.9.9",
46064631 "1.1.1.1",
4607- "208.67.222.222"
4632+ "2620:fe::fe",
4633+ "2606:4700:4700::1111"
46084634 ],
46094635 "default-address-pools": [
46104636 {
46114637 "base": "172.20.0.0/16",
46124638 "size": 24
4639+ },
4640+ {
4641+ "base": "fd00::/80",
4642+ "size": 96
46134643 }
46144644 ],
46154645 "userland-proxy": false,
0 commit comments