You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
log "systemd-resolved DNS setup complete (service + timer installed)"
1289
+
}
1290
+
1291
+
# Install and configure dnsmasq for split DNS on systems using classic /etc/resolv.conf.
1292
+
setup_dnsmasq_dns() {
1293
+
log "Setting up host DNS resolution via dnsmasq..."
1294
+
1295
+
# Check port 53 conflicts before installing
1296
+
if is_port_listening 53 tcp || is_port_listening 53 udp;then
1297
+
die "Port 53 is already in use on this host. Cannot set up dnsmasq for .dappnode resolution. Free up port 53 (check for existing dnsmasq, pihole, or other DNS services) and re-run the installer."
1298
+
fi
1299
+
1300
+
# Install dnsmasq
1301
+
log "Installing dnsmasq..."
1302
+
apt-get update -qq
1303
+
apt-get install -y dnsmasq
1304
+
1305
+
# Write split-DNS config
1306
+
local dnsmasq_conf="/etc/dnsmasq.d/dappnode.conf"
1307
+
log "Writing dnsmasq config to ${dnsmasq_conf}..."
1308
+
cat >"$dnsmasq_conf"<< 'DNSMASQEOF'
1309
+
########################################
1310
+
# DAppNode DNS routing (split DNS)
1311
+
########################################
1312
+
1313
+
# Route all *.dappnode domains to the DAppNode BIND container
1314
+
server=/dappnode/172.33.1.2
1315
+
1316
+
########################################
1317
+
# Upstream DNS (fallback)
1318
+
########################################
1319
+
1320
+
server=1.1.1.1
1321
+
server=8.8.8.8
1322
+
1323
+
########################################
1324
+
# Performance
1325
+
########################################
1326
+
1327
+
cache-size=1000
1328
+
1329
+
########################################
1330
+
# Security / Isolation
1331
+
########################################
1332
+
1333
+
listen-address=127.0.0.1
1334
+
bind-interfaces
1335
+
1336
+
########################################
1337
+
# DNS behavior
1338
+
########################################
1339
+
1340
+
# Never forward plain names (no dots)
1341
+
domain-needed
1342
+
1343
+
# Never forward reverse lookups for private IPs
1344
+
bogus-priv
1345
+
DNSMASQEOF
1346
+
1347
+
# Backup and update /etc/resolv.conf
1348
+
if [ -f /etc/resolv.conf ];then
1349
+
cp /etc/resolv.conf /etc/resolv.conf.dappnode.bak
1350
+
log "Backed up /etc/resolv.conf to /etc/resolv.conf.dappnode.bak"
1351
+
fi
1352
+
1353
+
# Write resolv.conf pointing to dnsmasq, with a public fallback
1354
+
cat > /etc/resolv.conf << 'RESOLVEOF'
1355
+
# Managed by DAppNode installer (--resolve-from-host)
1356
+
# Original backed up to /etc/resolv.conf.dappnode.bak
1357
+
nameserver 127.0.0.1
1358
+
nameserver 1.1.1.1
1359
+
RESOLVEOF
1360
+
1361
+
systemctl restart dnsmasq
1362
+
log "dnsmasq DNS setup complete"
1363
+
}
1364
+
1365
+
# Main dispatcher: detect the DNS subsystem and apply the appropriate solution.
1366
+
configure_host_dns_resolution() {
1367
+
if [[ "${RESOLVE_FROM_HOST}"!="true" ]];then
1368
+
return 0
1369
+
fi
1370
+
1371
+
if$IS_MACOS;then
1372
+
warn "Host DNS resolution (--resolve-from-host) is only supported on Linux. Ignoring on macOS."
1373
+
return 0
1374
+
fi
1375
+
1376
+
# Validate BIND is in the package set — both DNS paths forward to 172.33.1.2
1377
+
local has_bind=false
1378
+
local pkg
1379
+
forpkgin"${PKGS[@]}";do
1380
+
if [[ "$pkg"=="BIND" ]];then
1381
+
has_bind=true
1382
+
break
1383
+
fi
1384
+
done
1385
+
if [[ "$has_bind"!="true" ]];then
1386
+
die "--resolve-from-host requires the BIND package (DNS server at 172.33.1.2), but BIND is not in the package set. Add BIND to --packages or remove --resolve-from-host."
1387
+
fi
1388
+
1389
+
log "Configuring host DNS resolution for .dappnode domains..."
1390
+
1391
+
# Detect DNS subsystem
1392
+
if systemctl is-active --quiet systemd-resolved 2>/dev/null;then
1393
+
log "Detected systemd-resolved as the active DNS resolver"
log "Detected classic /etc/resolv.conf (no systemd-resolved)"
1397
+
setup_dnsmasq_dns
1398
+
else
1399
+
die "Unsupported DNS system. --resolve-from-host requires either systemd-resolved (Ubuntu 16.10+) or classic /etc/resolv.conf. Your system uses a different DNS configuration that this installer cannot automatically configure."
0 commit comments