From 170500e173f8893587956c78b427fd5a3c40bf08 Mon Sep 17 00:00:00 2001 From: Paul Payne Date: Thu, 9 Jul 2026 19:23:46 +0000 Subject: [PATCH] fix: Use configured dnsmasq IP instead of auto-detect The auto-detect picks the default route interface (wlan0 at 192.168.8.152) but dnsmasq is bound to eth0 (192.168.8.151). Now uses cloud.dnsmasq.ip from config as the Central IP for DNS entries, falling back to auto-detect only if not configured. Fixes DNS resolution failures when dnsmasq config points services to the wrong interface IP. Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/api/v1/helpers.go | 7 ++++++- internal/dnsmasq/config.go | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/internal/api/v1/helpers.go b/internal/api/v1/helpers.go index cc3d686..1ecf332 100644 --- a/internal/api/v1/helpers.go +++ b/internal/api/v1/helpers.go @@ -104,7 +104,12 @@ func (api *API) reconcileNetworking() { // DNS target IP depends on service type: // tcp-passthrough (k8s): DNS → k8s LB IP (LAN traffic goes direct to k8s) // http/static: DNS → Central IP (HAProxy terminates TLS) - centralIP, _ := network.GetWildCentralIP() + // Use the configured dnsmasq IP (eth0) as Central's IP, not auto-detected + // (auto-detect can pick wlan0 if that's the default route). + centralIP := globalCfg.Cloud.Dnsmasq.IP + if centralIP == "" { + centralIP, _ = network.GetWildCentralIP() + } if centralIP == "" { centralIP = "127.0.0.1" } diff --git a/internal/dnsmasq/config.go b/internal/dnsmasq/config.go index 5c89b3a..5ab0f83 100644 --- a/internal/dnsmasq/config.go +++ b/internal/dnsmasq/config.go @@ -36,12 +36,20 @@ func (g *ConfigGenerator) GetConfigPath() string { // Generate creates a dnsmasq configuration from the app config // It auto-detects the Wild Central server's IP address func (g *ConfigGenerator) Generate(cfg *config.GlobalConfig, clouds []config.InstanceConfig) string { - // Get the Wild Central IP address - dnsIP, err := network.GetWildCentralIP() - if err != nil { - slog.Error("failed to detect Wild Central IP", "component", "dnsmasq", "op", "generate", "error", err) - // Fall back to empty string if detection fails - dnsIP = "" + // Use configured dnsmasq IP (bound to eth0), falling back to auto-detect. + // Auto-detect can pick wlan0 if that's the default route, which is wrong + // when dnsmasq is only listening on eth0. + dnsIP := "" + if cfg != nil { + dnsIP = cfg.Cloud.Dnsmasq.IP + } + if dnsIP == "" { + var err error + dnsIP, err = network.GetWildCentralIP() + if err != nil { + slog.Error("failed to detect Wild Central IP", "component", "dnsmasq", "op", "generate", "error", err) + dnsIP = "" + } } resolution_section := ""