Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control the reverse lookup responses (PTR records) for statically defined domain name mappings in the blocky config #1570

Open
Tuxdude opened this issue Aug 8, 2024 · 2 comments

Comments

@Tuxdude
Copy link

Tuxdude commented Aug 8, 2024

I currently have a bunch of domain name records defined statically under the customDNS.mapping section of the blocky config file. I have multiple name records mapping to the same IP, which is quite typical when you run some sort of a reverse proxy (eg. nginx in my case) which hosts all these domain/subdomains, and will redirect the traffic to the corresponding backends for the service.

customDNS:
  customTTL: 1h
  filterUnmappedTypes: true
  mapping:
    foo1.mydomain.local: 10.1.1.8
    foo2.mydomain.local: 10.1.1.8
    foo3.mydomain.local: 10.1.1.8
    foo4.mydomain.local: 10.1.1.8

When I query for the PTR records (i.e. reverse lookup) on the host's IP (10.1.1.8 in the above example), I get all of these name records in the result.

$ dig -x 10.1.1.8

...
...
;; ANSWER SECTION:
8.1.1.10.in-addr.arpa. 3600 IN     PTR     foo3.mydomain.local.
8.1.1.10.in-addr.arpa. 3600 IN     PTR     foo1.mydomain.local.
8.1.1.10.in-addr.arpa. 3600 IN     PTR     foo4.mydomain.local.
8.1.1.10.in-addr.arpa. 3600 IN     PTR     foo2.mydomain.local.
...
...

The order of these records in the response are also non-deterministic. In cases where I have services performing such reverse lookups, it leads to odd domain names being printed irrelevant to that service.

It would be great if the blocky config provides better control of the PTR query responses, even if it means to define custom mappings controlling which results are returned.

Something along the lines of the following which only returns foo1 and foo4 in the response.

customDNS:
  customTTL: 1h
  filterUnmappedTypes: true
  mapping:
    foo1.mydomain.local: 10.1.1.8
    foo2.mydomain.local: 10.1.1.8
    foo3.mydomain.local: 10.1.1.8
    foo4.mydomain.local: 10.1.1.8
  reverseMapping:
    10.1.1.8: foo1.mydomain.local
    10.1.1.8: foo4.mydomain.local
@kristoftorok
Copy link

+1, it would be very useful

@Tuxdude
Copy link
Author

Tuxdude commented Sep 1, 2024

Since I run my own customized docker images in my homelab setup for almost all services, I have one for blocky as well. I decided to take a stab at implementing this myself and see if it will work, and it does.

Here is the patch file - https://github.com/TuxdudeHomeLab/docker-image-blocky/blob/master/patches/01-custom-dns-reverse-mapping-override.diff

The changes essentially apply a reverse DNS lookup override for the specified records and will ignore the current reverse DNS records automatically determined from the forward custom DNS mapping for that IP address. If there is no reverse DNS override specified for an IP, it will use the info from the forward records as it does now.

Example:

customDNS:
  customTTL: 1h
  filterUnmappedTypes: true
  mapping:
    a.example.com: 10.10.10.1
    b.example.com: 10.10.10.2
    c.example.com: 10.10.10.1
    d.example.com: 10.10.10.1
    e.example.com: 10.10.10.2
    f.example.com: 10.10.10.3
    g.example.com: 10.10.10.4
    h.example.com: 10.10.10.2
    i.example.com: 10.10.10.3
  reverseMappingOverride:
    10.10.10.1: a.example.com
    10.10.10.2: b.example.com
    10.10.10.3: f.example.com

Without this change:

$ dig +short -x 10.10.10.1
a.example.com.
c.example.com.
d.example.com.

$ dig +short -x 10.10.10.2
h.example.com.
b.example.com.
e.example.com.

$ dig +short -x 10.10.10.3
i.example.com.
f.example.com.

$ dig +short -x 10.10.10.4
g.example.com.

With this change:

$ dig +short -x 10.10.10.1
a.example.com.

$ dig +short -x 10.10.10.2
b.example.com.

$ dig +short -x 10.10.10.3
f.example.com.

$ dig +short -x 10.10.10.4
g.example.com.

If there is interest in this feature, I am happy to make this a proper pull request and update tests, etc. Will be interested to know from the owners/maintainers of blocky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants