[GH-ISSUE #54] Server does not handle unquallified domains well in some conditions #23

Closed
opened 2026-02-26 04:33:48 +03:00 by kerem · 8 comments
Owner

Originally created by @firelizzard18 on GitHub (Dec 4, 2017).
Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/54

The core issue here is when A) /etc/resolv.conf specifies DNS search domains and B) I request an unqualified hostname owned by a container, dns-proxy-server queries the nameservers before resolving the hostname to the container.

  1. My network has DNS search domains
  2. I need to use custom, internal name servers
  3. These name servers respond very slowly to requests for domains that don't exist
  4. When I nslookup example-app., I get a prompt response
  5. When I nslookup example-app, the server appends the search domain, queries the name servers, and waits for those queries to fail before it returns the appropriate response

config:

{
    "remoteDnsServers": [
        [10,2,3,4],
        [10,2,3,5]
    ]
}

/etc/resolv.conf:

# Generated by NetworkManager
search ExampleDomain.local exampledomain.local
# nameserver 10.2.3.4 # dps-comment
# nameserver 10.2.3.5 # dps-comment
nameserver 172.17.0.7 # dps-entry

nslookup example-app.:

% nslookup example-app.
Server:         172.17.0.7
Address:        172.17.0.7#53

Non-authoritative answer:
Name:   example-app
Address: 172.17.0.4

Logs:

dns-proxy-server    | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=begin, reqId=59670, questions=1, question=example-app., type=TypeA
dns-proxy-server    | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
dns-proxy-server    | 17-12-04 21:07:01.256 DEB id=39, m=Solve solver=docker, status=solved-key, solver=docker, hostname=example-app, ip=172.17.0.4
dns-proxy-server    | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1
dns-proxy-server    | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=example-app.     0       IN      A       172.17.0.4

nslookup example-app:

% nslookup example-app
;; connection timed out; trying next origin
;; connection timed out; trying next origin
Server:         172.17.0.7
Address:        172.17.0.7#53

Non-authoritative answer:
Name:   example-app
Address: 172.17.0.4

Logs:

dns-proxy-server    | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=begin, reqId=58655, questions=1, question=example-app.ExampleDomain.local., type=TypeA
dns-proxy-server    | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
dns-proxy-server    | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=begin, solver=*proxy.localDnsSolver
dns-proxy-server    | 17-12-04 21:10:57.032 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:10:57.032 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:10:57.032 INF id=42, m=LoadConfiguration status=begin, confPath=/app/conf/config.json
dns-proxy-server    | 17-12-04 21:10:57.032 INF id=42, m=LoadConfiguration status=openingFile
dns-proxy-server    | 17-12-04 21:10:57.033 INF id=42, m=LoadConfiguration status=success
dns-proxy-server    | 17-12-04 21:10:57.033 DEB id=42, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env
dns-proxy-server    | 17-12-04 21:10:57.033 DEB id=42, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver
dns-proxy-server    | 17-12-04 21:10:57.033 DEB id=42, m=Solve solver=remote, status=servers-from-cache
dns-proxy-server    | 17-12-04 21:10:57.033 DEB id=42, m=Solve status=format-server, server=10.20.30.9
dns-proxy-server    | 17-12-04 21:10:57.033 INF id=42, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:10:57.033 DEB id=42, m=Solve status=format-server, server=10.20.30.18
dns-proxy-server    | 17-12-04 21:10:57.034 INF id=42, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:10:57.034 DEB id=42, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=begin, reqId=58655, questions=1, question=example-app.ExampleDomain.local., type=TypeA
dns-proxy-server    | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
dns-proxy-server    | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=begin, solver=*proxy.localDnsSolver
dns-proxy-server    | 17-12-04 21:11:02.032 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:02.032 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:02.032 INF id=43, m=LoadConfiguration status=begin, confPath=/app/conf/config.json
dns-proxy-server    | 17-12-04 21:11:02.033 INF id=43, m=LoadConfiguration status=openingFile
dns-proxy-server    | 17-12-04 21:11:02.033 INF id=43, m=LoadConfiguration status=success
dns-proxy-server    | 17-12-04 21:11:02.033 DEB id=43, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env
dns-proxy-server    | 17-12-04 21:11:02.033 DEB id=43, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver
dns-proxy-server    | 17-12-04 21:11:02.033 DEB id=43, m=Solve solver=remote, status=servers-from-cache
dns-proxy-server    | 17-12-04 21:11:02.033 DEB id=43, m=Solve status=format-server, server=10.20.30.9
dns-proxy-server    | 17-12-04 21:11:02.033 INF id=43, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:02.033 DEB id=43, m=Solve status=format-server, server=10.20.30.18
dns-proxy-server    | 17-12-04 21:11:02.034 INF id=43, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:02.034 DEB id=43, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=begin, reqId=58655, questions=1, question=example-app.ExampleDomain.local., type=TypeA
dns-proxy-server    | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
dns-proxy-server    | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=begin, solver=*proxy.localDnsSolver
dns-proxy-server    | 17-12-04 21:11:07.032 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:07.032 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:07.033 INF id=44, m=LoadConfiguration status=begin, confPath=/app/conf/config.json
dns-proxy-server    | 17-12-04 21:11:07.033 INF id=44, m=LoadConfiguration status=openingFile
dns-proxy-server    | 17-12-04 21:11:07.033 INF id=44, m=LoadConfiguration status=success
dns-proxy-server    | 17-12-04 21:11:07.033 DEB id=44, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env
dns-proxy-server    | 17-12-04 21:11:07.033 DEB id=44, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver
dns-proxy-server    | 17-12-04 21:11:07.033 DEB id=44, m=Solve solver=remote, status=servers-from-cache
dns-proxy-server    | 17-12-04 21:11:07.033 DEB id=44, m=Solve status=format-server, server=10.20.30.9
dns-proxy-server    | 17-12-04 21:11:07.034 INF id=44, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:07.034 DEB id=44, m=Solve status=format-server, server=10.20.30.18
dns-proxy-server    | 17-12-04 21:11:07.035 INF id=44, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:07.035 DEB id=44, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, reqId=41200, questions=1, question=example-app.ExampleDomain.local., type=TypeA
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, solver=*proxy.localDnsSolver
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local
dns-proxy-server    | 17-12-04 21:11:12.033 INF id=45, m=LoadConfiguration status=begin, confPath=/app/conf/config.json
dns-proxy-server    | 17-12-04 21:11:12.033 INF id=45, m=LoadConfiguration status=openingFile
dns-proxy-server    | 17-12-04 21:11:12.033 INF id=45, m=LoadConfiguration status=success
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=Solve solver=remote, status=servers-from-cache
dns-proxy-server    | 17-12-04 21:11:12.033 DEB id=45, m=Solve status=format-server, server=10.20.30.9
dns-proxy-server    | 17-12-04 21:11:12.034 INF id=45, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:12.034 DEB id=45, m=Solve status=format-server, server=10.20.30.18
dns-proxy-server    | 17-12-04 21:11:12.036 INF id=45, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:12.036 DEB id=45, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, reqId=37728, questions=1, question=example-app., type=TypeA
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=Solve solver=docker, status=solved-key, solver=docker, hostname=example-app, ip=172.17.0.4
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=example-app.     0       IN      A       172.17.0.4
Originally created by @firelizzard18 on GitHub (Dec 4, 2017). Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/54 The core issue here is when A) `/etc/resolv.conf` specifies DNS search domains and B) I request an unqualified hostname owned by a container, `dns-proxy-server` queries the nameservers before resolving the hostname to the container. 1. My network has DNS search domains 2. I need to use custom, internal name servers 3. These name servers respond very slowly to requests for domains that don't exist 4. When I `nslookup example-app.`, I get a prompt response 5. When I `nslookup example-app`, the server appends the search domain, queries the name servers, and waits for those queries to fail before it returns the appropriate response config: ```json { "remoteDnsServers": [ [10,2,3,4], [10,2,3,5] ] } ``` `/etc/resolv.conf`: ``` # Generated by NetworkManager search ExampleDomain.local exampledomain.local # nameserver 10.2.3.4 # dps-comment # nameserver 10.2.3.5 # dps-comment nameserver 172.17.0.7 # dps-entry ``` `nslookup example-app.`: ``` % nslookup example-app. Server: 172.17.0.7 Address: 172.17.0.7#53 Non-authoritative answer: Name: example-app Address: 172.17.0.4 ``` Logs: ``` dns-proxy-server | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=begin, reqId=59670, questions=1, question=example-app., type=TypeA dns-proxy-server | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver dns-proxy-server | 17-12-04 21:07:01.256 DEB id=39, m=Solve solver=docker, status=solved-key, solver=docker, hostname=example-app, ip=172.17.0.4 dns-proxy-server | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1 dns-proxy-server | 17-12-04 21:07:01.256 DEB id=39, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=example-app. 0 IN A 172.17.0.4 ``` `nslookup example-app`: ``` % nslookup example-app ;; connection timed out; trying next origin ;; connection timed out; trying next origin Server: 172.17.0.7 Address: 172.17.0.7#53 Non-authoritative answer: Name: example-app Address: 172.17.0.4 ``` Logs: ``` dns-proxy-server | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=begin, reqId=58655, questions=1, question=example-app.ExampleDomain.local., type=TypeA dns-proxy-server | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver dns-proxy-server | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:10:57.032 DEB id=42, m=handleQuestion status=begin, solver=*proxy.localDnsSolver dns-proxy-server | 17-12-04 21:10:57.032 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:10:57.032 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:10:57.032 INF id=42, m=LoadConfiguration status=begin, confPath=/app/conf/config.json dns-proxy-server | 17-12-04 21:10:57.032 INF id=42, m=LoadConfiguration status=openingFile dns-proxy-server | 17-12-04 21:10:57.033 INF id=42, m=LoadConfiguration status=success dns-proxy-server | 17-12-04 21:10:57.033 DEB id=42, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env dns-proxy-server | 17-12-04 21:10:57.033 DEB id=42, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver dns-proxy-server | 17-12-04 21:10:57.033 DEB id=42, m=Solve solver=remote, status=servers-from-cache dns-proxy-server | 17-12-04 21:10:57.033 DEB id=42, m=Solve status=format-server, server=10.20.30.9 dns-proxy-server | 17-12-04 21:10:57.033 INF id=42, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:10:57.033 DEB id=42, m=Solve status=format-server, server=10.20.30.18 dns-proxy-server | 17-12-04 21:10:57.034 INF id=42, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:10:57.034 DEB id=42, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=begin, reqId=58655, questions=1, question=example-app.ExampleDomain.local., type=TypeA dns-proxy-server | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver dns-proxy-server | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:02.032 DEB id=43, m=handleQuestion status=begin, solver=*proxy.localDnsSolver dns-proxy-server | 17-12-04 21:11:02.032 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:02.032 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:02.032 INF id=43, m=LoadConfiguration status=begin, confPath=/app/conf/config.json dns-proxy-server | 17-12-04 21:11:02.033 INF id=43, m=LoadConfiguration status=openingFile dns-proxy-server | 17-12-04 21:11:02.033 INF id=43, m=LoadConfiguration status=success dns-proxy-server | 17-12-04 21:11:02.033 DEB id=43, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env dns-proxy-server | 17-12-04 21:11:02.033 DEB id=43, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver dns-proxy-server | 17-12-04 21:11:02.033 DEB id=43, m=Solve solver=remote, status=servers-from-cache dns-proxy-server | 17-12-04 21:11:02.033 DEB id=43, m=Solve status=format-server, server=10.20.30.9 dns-proxy-server | 17-12-04 21:11:02.033 INF id=43, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:02.033 DEB id=43, m=Solve status=format-server, server=10.20.30.18 dns-proxy-server | 17-12-04 21:11:02.034 INF id=43, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:02.034 DEB id=43, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=begin, reqId=58655, questions=1, question=example-app.ExampleDomain.local., type=TypeA dns-proxy-server | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver dns-proxy-server | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:07.032 DEB id=44, m=handleQuestion status=begin, solver=*proxy.localDnsSolver dns-proxy-server | 17-12-04 21:11:07.032 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:07.032 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:07.033 INF id=44, m=LoadConfiguration status=begin, confPath=/app/conf/config.json dns-proxy-server | 17-12-04 21:11:07.033 INF id=44, m=LoadConfiguration status=openingFile dns-proxy-server | 17-12-04 21:11:07.033 INF id=44, m=LoadConfiguration status=success dns-proxy-server | 17-12-04 21:11:07.033 DEB id=44, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env dns-proxy-server | 17-12-04 21:11:07.033 DEB id=44, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver dns-proxy-server | 17-12-04 21:11:07.033 DEB id=44, m=Solve solver=remote, status=servers-from-cache dns-proxy-server | 17-12-04 21:11:07.033 DEB id=44, m=Solve status=format-server, server=10.20.30.9 dns-proxy-server | 17-12-04 21:11:07.034 INF id=44, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:07.034 DEB id=44, m=Solve status=format-server, server=10.20.30.18 dns-proxy-server | 17-12-04 21:11:07.035 INF id=44, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:07.035 DEB id=44, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, reqId=41200, questions=1, question=example-app.ExampleDomain.local., type=TypeA dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, solver=*proxy.localDnsSolver dns-proxy-server | 17-12-04 21:11:12.033 DEB id=1, m=ContainsKey status=notfound, key=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:12.033 DEB id=1, m=Solve solver=local, status=hot-load, hostname=example-app.ExampleDomain.local dns-proxy-server | 17-12-04 21:11:12.033 INF id=45, m=LoadConfiguration status=begin, confPath=/app/conf/config.json dns-proxy-server | 17-12-04 21:11:12.033 INF id=45, m=LoadConfiguration status=openingFile dns-proxy-server | 17-12-04 21:11:12.033 INF id=45, m=LoadConfiguration status=success dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=original env dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=handleQuestion status=begin, solver=*proxy.remoteDnsSolver dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=Solve solver=remote, status=servers-from-cache dns-proxy-server | 17-12-04 21:11:12.033 DEB id=45, m=Solve status=format-server, server=10.20.30.9 dns-proxy-server | 17-12-04 21:11:12.034 INF id=45, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:12.034 DEB id=45, m=Solve status=format-server, server=10.20.30.18 dns-proxy-server | 17-12-04 21:11:12.036 INF id=45, m=Solve status=bad-code, name=example-app.ExampleDomain.local., rcode=3, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:12.036 DEB id=45, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=invalid-answer-name, name=example-app.ExampleDomain.local., rcode=3 dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, reqId=37728, questions=1, question=example-app., type=TypeA dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=Solve solver=docker, status=solved-key, solver=docker, hostname=example-app, ip=172.17.0.4 dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1 dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=example-app. 0 IN A 172.17.0.4 ```
kerem 2026-02-26 04:33:48 +03:00
Author
Owner

@mageddo commented on GitHub (Dec 4, 2017):

@firelizzard18 Thank you for the very well explained case, I will work on that

<!-- gh-comment-id:349112439 --> @mageddo commented on GitHub (Dec 4, 2017): @firelizzard18 Thank you for the very well explained case, I will work on that
Author
Owner

@mageddo commented on GitHub (Dec 4, 2017):

@firelizzard18 What do you think would be the expected behavior here?

<!-- gh-comment-id:349133271 --> @mageddo commented on GitHub (Dec 4, 2017): @firelizzard18 What do you think would be the expected behavior here?
Author
Owner

@mageddo commented on GitHub (Dec 5, 2017):

@firelizzard18 I tried to reproduce your issue then I got the same problem. Anyway I solved using another approach(specifying the domain sufix at container hostname)

/etc/resolv.conf

# nameserver 127.0.0.53 # dps-comment
nameserver 172.17.0.3 # dps-entry
search intranet

starting container

docker run --rm --hostname myapp.intranet -e HOSTNAMES=myapp.dev -it debian:9  bash

testing it

nslookup myapp
Server:		172.17.0.3
Address:	172.17.0.3#53

Non-authoritative answer:
Name:	myapp.intranet
Address: 172.17.0.2

or solving by custom domain suffix

nslookup myapp.dev
Server:		172.17.0.3
Address:	172.17.0.3#53

Non-authoritative answer:
Name:	myapp.dev
Address: 172.17.0.2

Now I want to understand, does it works and is ok for you or you have some point? Thank you

<!-- gh-comment-id:349158940 --> @mageddo commented on GitHub (Dec 5, 2017): @firelizzard18 I tried to reproduce your issue then I got the same problem. Anyway I solved using another approach(specifying the domain sufix at container hostname) /etc/resolv.conf ``` # nameserver 127.0.0.53 # dps-comment nameserver 172.17.0.3 # dps-entry search intranet ``` starting container docker run --rm --hostname myapp.intranet -e HOSTNAMES=myapp.dev -it debian:9 bash testing it ``` nslookup myapp Server: 172.17.0.3 Address: 172.17.0.3#53 Non-authoritative answer: Name: myapp.intranet Address: 172.17.0.2 ``` or solving by custom domain suffix ``` nslookup myapp.dev Server: 172.17.0.3 Address: 172.17.0.3#53 Non-authoritative answer: Name: myapp.dev Address: 172.17.0.2 ``` Now I want to understand, does it works and is ok for you or you have some point? Thank you
Author
Owner

@firelizzard18 commented on GitHub (Dec 5, 2017):

I expect dns-proxy-server to first try to find a match for the query within the docker containers' hostnames, regardless of whether the name in the query is fully-qualified.

The diagram in the readme shows the following resolution strategy:

  1. Look for a match in docker
  2. Look for a match in the local db
  3. Fallback to remote resolvers

It seems to me that this strategy holds true when the query specifies a fully-qualified domain name. But when the query specifies an unqualified domain name, dns-proxy-server does not follow the above, as it queries remote resolvers before looking for a match in docker. Or perhaps it tries the entire resolution strategy using the qualified name and then the entire strategy with the unqualified name.

I have a container server that is running multiple containerized services. I need all of the services to be accessible on the default port (HTTP), so I need to use virtual hosts. Therefore I must use a reverse proxy.

One of the apps is example-app, accessible as http://example-app or http://example-app.ExampleDomain.local. This app is running in a container configured with a hostname of container-example-app. So I need to set up a reverse proxy from example-app and example-app.ExampleDomain.local to container-example-app. However container-example-app only means anything in the context of the container server so it shouldn't be suffixed with ExampleDomain.local.

<!-- gh-comment-id:349455627 --> @firelizzard18 commented on GitHub (Dec 5, 2017): I expect `dns-proxy-server` to first try to find a match for the query within the docker containers' hostnames, regardless of whether the name in the query is fully-qualified. The diagram in the readme shows the following resolution strategy: 1. Look for a match in docker 2. Look for a match in the local db 3. Fallback to remote resolvers It seems to me that this strategy holds true when the query specifies a fully-qualified domain name. But when the query specifies an unqualified domain name, `dns-proxy-server` does not follow the above, as it queries remote resolvers before looking for a match in docker. Or perhaps it tries the entire resolution strategy using the qualified name and then the entire strategy with the unqualified name. I have a container server that is running multiple containerized services. I need all of the services to be accessible on the default port (HTTP), so I need to use virtual hosts. Therefore I must use a reverse proxy. One of the apps is `example-app`, accessible as `http://example-app` or `http://example-app.ExampleDomain.local`. This app is running in a container configured with a hostname of `container-example-app`. So I need to set up a reverse proxy from `example-app` and `example-app.ExampleDomain.local` to `container-example-app`. However `container-example-app` only means anything in the context of the container server so it shouldn't be suffixed with `ExampleDomain.local`.
Author
Owner

@mageddo commented on GitHub (Dec 8, 2017):

Sorry for the too late answer, I took a while to understand this problem. The conclusion was:

DPS can solve names without domains e.g. container-example-app anyway it is not working with nslookup for me(I don't know why yet), I proved that with dig

Starting container for tests

$ docker run --rm --name nginx --hostname nginx1 -it nginx:1.10

Testing hostname with dig

$ dig nginx1  @172.22.0.5
; <<>> DiG 9.9.5-3ubuntu0.8-Ubuntu <<>> nginx1 @172.22.0.5
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32858
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;nginx1.				IN	A

;; ANSWER SECTION:
nginx1.			0	IN	A	172.22.0.6

;; Query time: 1 msec
;; SERVER: 172.22.0.5#53(172.22.0.5)
;; WHEN: Fri Dec 08 17:06:57 BRST 2017
;; MSG SIZE  rcvd: 46

DPS logs

17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=begin, reqId=7408, questions=1, question=nginx1., type=TypeA
17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
17-12-08 21:36:52.736 DEB id=75, m=Solve solver=docker, status=solved-key, solver=docker, hostname=nginx1, ip=172.22.0.6
17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1
17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=nginx1.	0	IN	A	172.22.0.6

or using a go script

main.go

package main

import (
	"context"
	"fmt"
	"net"
)

func main(){
	r, err := net.DefaultResolver.LookupHost(context.Background(), "nginx1")
	fmt.Printf("%v %v\n", r, err);
}

out

[172.22.0.6] <nil>

DPS LOG

17-12-08 21:43:44.165 DEB id=90, m=handleQuestion status=begin, reqId=57197, questions=1, question=nginx1.ExampleDomain.local., type=TypeAAAA
17-12-08 21:43:44.165 DEB id=91, m=handleQuestion status=begin, reqId=13586, questions=1, question=nginx1.ExampleDomain.local., type=TypeA
17-12-08 21:43:44.165 DEB id=90, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found nginx1.ExampleDomain.local
17-12-08 21:43:44.165 DEB id=91, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found nginx1.ExampleDomain.local
17-12-08 21:43:44.166 DEB id=90, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=hostname not found nginx1.ExampleDomain.local
17-12-08 21:43:44.166 DEB id=91, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=hostname not found nginx1.ExampleDomain.local
17-12-08 21:43:44.266 DEB id=90, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=answer-can-not-be-null, err=read udp 172.22.0.5:33999->8.8.8.8:53: i/o timeout
17-12-08 21:43:44.266 DEB id=91, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=answer-can-not-be-null, err=read udp 172.22.0.5:35430->8.8.8.8:53: i/o timeout


17-12-08 21:43:54.166 DEB id=95, m=handleQuestion status=begin, reqId=25443, questions=1, question=nginx1., type=TypeA
17-12-08 21:43:54.166 DEB id=96, m=handleQuestion status=begin, reqId=58924, questions=1, question=nginx1., type=TypeAAAA
17-12-08 21:43:54.166 DEB id=96, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=nginx1.	0	IN	A	172.22.0.6
17-12-08 21:43:54.166 DEB id=95, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=nginx1.	0	IN	A	172.22.0.6

Back to your problem...

As you can see the go application asks the hostname IP to linux then Linux asks to DPS, as your system has a search domain and you are looking for a name that have not a domain Linux first try to solve the hostname appended with the configured search domain, this way DPS receives a request like nginx1.ExampleDomain.local and don't found a container with that name(and that is correct), then proxy it to a remote server, as you mentioned your remote server is slow to answer for a name that doesn't exists probably Linux is aborting the connection before try to solve nginx1 (which is tried last).

The conclusion is that I think we can solve your problem by limiting the remote server timeout to respond in DPS, anyway it is not implemented yet, I might it is not hard to do.

If you look to the first log you sent you can see the example-app being solved but probably your client doesn't waited it responds.

dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, reqId=37728, questions=1, question=example-app., type=TypeA
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=Solve solver=docker, status=solved-key, solver=docker, hostname=example-app, ip=172.17.0.4
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1
dns-proxy-server    | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=example-app.     0       IN      A       172.17.0.4

DPS = Dns Proxy Server

<!-- gh-comment-id:350385982 --> @mageddo commented on GitHub (Dec 8, 2017): Sorry for the too late answer, I took a while to understand this problem. The conclusion was: **DPS** can solve names without domains e.g. `container-example-app` anyway it is not working with **nslookup** for me(I don't know why yet), I proved that with **dig** Starting container for tests ``` $ docker run --rm --name nginx --hostname nginx1 -it nginx:1.10 ``` Testing hostname with dig ``` $ dig nginx1 @172.22.0.5 ; <<>> DiG 9.9.5-3ubuntu0.8-Ubuntu <<>> nginx1 @172.22.0.5 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32858 ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;nginx1. IN A ;; ANSWER SECTION: nginx1. 0 IN A 172.22.0.6 ;; Query time: 1 msec ;; SERVER: 172.22.0.5#53(172.22.0.5) ;; WHEN: Fri Dec 08 17:06:57 BRST 2017 ;; MSG SIZE rcvd: 46 ``` DPS logs ``` 17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=begin, reqId=7408, questions=1, question=nginx1., type=TypeA 17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver 17-12-08 21:36:52.736 DEB id=75, m=Solve solver=docker, status=solved-key, solver=docker, hostname=nginx1, ip=172.22.0.6 17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1 17-12-08 21:36:52.736 DEB id=75, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=nginx1. 0 IN A 172.22.0.6 ``` or using a go script main.go ```go package main import ( "context" "fmt" "net" ) func main(){ r, err := net.DefaultResolver.LookupHost(context.Background(), "nginx1") fmt.Printf("%v %v\n", r, err); } ``` out ``` [172.22.0.6] <nil> ``` DPS LOG ``` 17-12-08 21:43:44.165 DEB id=90, m=handleQuestion status=begin, reqId=57197, questions=1, question=nginx1.ExampleDomain.local., type=TypeAAAA 17-12-08 21:43:44.165 DEB id=91, m=handleQuestion status=begin, reqId=13586, questions=1, question=nginx1.ExampleDomain.local., type=TypeA 17-12-08 21:43:44.165 DEB id=90, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found nginx1.ExampleDomain.local 17-12-08 21:43:44.165 DEB id=91, m=handleQuestion status=not-resolved, solver=*proxy.DockerDnsSolver, err=hostname not found nginx1.ExampleDomain.local 17-12-08 21:43:44.166 DEB id=90, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=hostname not found nginx1.ExampleDomain.local 17-12-08 21:43:44.166 DEB id=91, m=handleQuestion status=not-resolved, solver=*proxy.localDnsSolver, err=hostname not found nginx1.ExampleDomain.local 17-12-08 21:43:44.266 DEB id=90, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=answer-can-not-be-null, err=read udp 172.22.0.5:33999->8.8.8.8:53: i/o timeout 17-12-08 21:43:44.266 DEB id=91, m=handleQuestion status=not-resolved, solver=*proxy.remoteDnsSolver, err=status=answer-can-not-be-null, err=read udp 172.22.0.5:35430->8.8.8.8:53: i/o timeout 17-12-08 21:43:54.166 DEB id=95, m=handleQuestion status=begin, reqId=25443, questions=1, question=nginx1., type=TypeA 17-12-08 21:43:54.166 DEB id=96, m=handleQuestion status=begin, reqId=58924, questions=1, question=nginx1., type=TypeAAAA 17-12-08 21:43:54.166 DEB id=96, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=nginx1. 0 IN A 172.22.0.6 17-12-08 21:43:54.166 DEB id=95, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=nginx1. 0 IN A 172.22.0.6 ``` Back to your problem... As you can see the go application asks the hostname IP to linux then Linux asks to DPS, as your system has a **search domain** and you are looking for a name that have not a domain Linux first try to solve the hostname appended with the configured search domain, this way DPS receives a request like `nginx1.ExampleDomain.local` and don't found a container with that name(and that is correct), then proxy it to a remote server, as you mentioned your remote server is slow to answer for a name that doesn't exists probably Linux is aborting the connection before try to solve `nginx1` (which is tried last). The conclusion is that I think we can solve your problem by limiting the remote server timeout to respond in DPS, anyway it is not implemented yet, I might it is not hard to do. If you look to the first log you sent you can see the `example-app` being solved but probably your client doesn't waited it responds. ``` dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, reqId=37728, questions=1, question=example-app., type=TypeA dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=begin, solver=*proxy.DockerDnsSolver dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=Solve solver=docker, status=solved-key, solver=docker, hostname=example-app, ip=172.17.0.4 dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=answer-found, solver=*proxy.DockerDnsSolver, length=1 dns-proxy-server | 17-12-04 21:11:17.033 DEB id=46, m=handleQuestion status=resolved, solver=*proxy.DockerDnsSolver, alength=1, answer=example-app. 0 IN A 172.17.0.4 ``` DPS = Dns Proxy Server
Author
Owner

@mageddo commented on GitHub (Dec 8, 2017):

See resolv.conf reference

Resolver queries having fewer than ndots dots
(default is 1) in them will be attempted using each component
of the search path in turn until a match is found

And this stack exchange answer

To summarize the above, assuming no change from the defaults mentioned above, if something gets to the resolver that has no dots in it, the resolver will try adding localdomain.com to it.

I understood:

If you have a search domain configured then Linux will ask DNS Server by domain + search domain IF domain have not dots, then there is not guarantee that Linux will ask example-app (without search domain) to DPS, I think it will depend the client resolver implementation. After all that's why you (and my last example) are getting this behavior.

Back to my first solution maybe you might use .docker, .container, .app in the docker container hostnames suffix, it can make more sense rather than use ExampleDomain.local if remove the search is not a option.

<!-- gh-comment-id:350389315 --> @mageddo commented on GitHub (Dec 8, 2017): See [resolv.conf reference](http://man7.org/linux/man-pages/man5/resolv.conf.5.html) > Resolver queries having fewer than ndots dots (default is 1) in them will be attempted using each component of the search path in turn until a match is found And this [stack exchange answer](https://superuser.com/a/570095/441495) > To summarize the above, assuming no change from the defaults mentioned above, if something gets to the resolver that has no dots in it, the resolver will try adding **localdomain.com** to it. I understood: If you have a search domain configured then Linux will ask DNS Server by `domain` + `search domain` IF domain have not dots, then there is not guarantee that Linux will ask `example-app` (without search domain) to DPS, I think it will depend the client resolver implementation. After all that's why you (and my last example) are getting this behavior. Back to my first solution maybe you might use `.docker`, `.container`, `.app` in the docker container hostnames suffix, it can make more sense rather than use `ExampleDomain.local` if remove the search is not a option.
Author
Owner

@mageddo commented on GitHub (Dec 8, 2017):

Just to let it clear, DPS look for a container with same hostname as requested by the client, it don't try to match domain prefixes

<!-- gh-comment-id:350392318 --> @mageddo commented on GitHub (Dec 8, 2017): Just to let it clear, DPS look for a container with same hostname as requested by the client, it don't try to match domain prefixes
Author
Owner

@firelizzard18 commented on GitHub (Dec 9, 2017):

Ah. For now I'll probably use some kind of suffix like you suggest. Or maybe talk to IT and figure out why the upstream DNS servers take so long.

Adding DPS configuration for upstream DNS request timeout could be nice, but I think that's a separate issue and not how I want to solve my problem.

<!-- gh-comment-id:350410640 --> @firelizzard18 commented on GitHub (Dec 9, 2017): Ah. For now I'll probably use some kind of suffix like you suggest. Or maybe talk to IT and figure out why the upstream DNS servers take so long. Adding DPS configuration for upstream DNS request timeout could be nice, but I think that's a separate issue and not how I want to solve my problem.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/dns-proxy-server-mageddo#23
No description provided.