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) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 19:23:46 +00:00
parent 900d25bab2
commit 170500e173
2 changed files with 20 additions and 7 deletions

View File

@@ -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"
}

View File

@@ -36,13 +36,21 @@ 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()
// 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)
// Fall back to empty string if detection fails
dnsIP = ""
}
}
resolution_section := ""
for _, cloud := range clouds {