From d17f83a379fd6b8f842da1e0a3ea5eeb08bc2de4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 11 Aug 2020 07:56:51 +0200 Subject: [PATCH] Improve nameserver auth IP check --- nameserver/nameserver.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nameserver/nameserver.go b/nameserver/nameserver.go index 91fe4223..f7a3b736 100644 --- a/nameserver/nameserver.go +++ b/nameserver/nameserver.go @@ -28,7 +28,6 @@ var ( dnsServer *dns.Server listenAddress = "0.0.0.0:53" - ipv4Localhost = net.IPv4(127, 0, 0, 1) localhostRRs []dns.RR ) @@ -146,8 +145,8 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, query *dns.Msg) er log.Warningf("nameserver: could not get remote address of request for %s%s, ignoring", q.FQDN, q.QType) return nil } - if !remoteAddr.IP.Equal(ipv4Localhost) { - // if request is not coming from 127.0.0.1, check if it's really local + if !netutils.IPIsLocalhost(remoteAddr.IP) { + // If request is not from a localhost address, check it it's really local. localAddr, ok := w.RemoteAddr().(*net.UDPAddr) if !ok {