mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
all: fallback to br0 as nameserver if 127.0.0.1 is used
On Firewalla, lo interface is excluded in all dnsmasq settings of all interfaces, to prevent conflicts. The one that ctrld adds in dnsmasq_local directory could not work if there're multiple dnsmasq configs for multiple interfaces (real example from an user who uses VLAN in router setup). Instead, if we detect 127.0.0.1 on Firewalla, fallback to "br0" interface IP address instead.
This commit is contained in:
committed by
Cuong Manh Le
parent
eaa907a647
commit
cc28b92935
@@ -982,6 +982,10 @@ func uninstall(p *prog, s service.Service) {
|
||||
}
|
||||
initLogging()
|
||||
if doTasks(tasks) {
|
||||
if err := router.PostUninstall(svcConfig); err != nil {
|
||||
mainLog.Warn().Err(err).Msg("post uninstallation failed, please check system/service log for details error")
|
||||
return
|
||||
}
|
||||
// Stop already reset DNS on router.
|
||||
if router.Name() == "" {
|
||||
p.resetDNS()
|
||||
|
||||
+17
-1
@@ -235,7 +235,23 @@ func (p *prog) setDNS() {
|
||||
return
|
||||
}
|
||||
logger.Debug().Msg("setting DNS for interface")
|
||||
if err := setDNS(netIface, []string{cfg.Listener["0"].IP}); err != nil {
|
||||
ns := cfg.Listener["0"].IP
|
||||
if router.Name() == router.Firewalla && ns == "127.0.0.1" {
|
||||
// On Firewalla, the lo interface is excluded in all dnsmasq settings of all interfaces.
|
||||
// Thus, we use "br0" as the nameserver in /etc/resolv.conf file.
|
||||
logger.Warn().Msg("127.0.0.1 won't work on Firewalla")
|
||||
if netIface, err := net.InterfaceByName("br0"); err == nil {
|
||||
addrs, _ := netIface.Addrs()
|
||||
for _, addr := range addrs {
|
||||
if netIP, ok := addr.(*net.IPNet); ok && netIP.IP.To4() != nil {
|
||||
logger.Warn().Msg("using br0 interface IP address as DNS server")
|
||||
ns = netIP.IP.To4().String()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := setDNS(netIface, []string{ns}); err != nil {
|
||||
logger.Error().Err(err).Msgf("could not set DNS for interface")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user