Multiple local A records for a single hostname

Setting up a Kubernetes local cluster at home and I'd like to be able set more than one IP address for hostnames running on it. Now the UI doesn't seem to accept CSV list of IP address or lets me add the same hostname with different IP address multiple times. Is there another way to achieve this?

Could you elaborate a bit more on what are you trying to achieve by pointing a single hostname to mutiple IP addresses?

You could add multiple lines to your Pi-hole host's /etc/hosts to that effect.

Note that your client is free to pick any of the IP addresses you provide for a hostname, though often it would just use the first entry returned.

Could you elaborate a bit more on what are you trying to achieve by pointing a single hostname to mutiple IP addresses?

Sure, so the cluster has the following IP addresses:

  • 172.31.13.6
  • 172.31.13.12
  • 172.31.13.99

And I want to point k8s.home.net at all 3 those IP addresses using the local DNS. So that if any of those nodes goes down the others can pick up incoming traffic.

You could add multiple lines to your Pi-hole host's /etc/hosts to that effect.

He didn't consider that, does that also work when you have unbound set up?

Note that your client is free to pick any of the IP addresses you provide for a hostname, though often it would just use the first entry returned.

Yes, and this is where happy eyeballs will kick in and it will try them one by one. Which is why I want at least more than one of them on it.

This is independent of your upstream DNS resolver. The local domain name mapping to IP's happens in Pi-hole, which is prior to unbound. If Pi-hole knows the answer, nothing is forwarded to unbound for resolution.

1 Like

For an upstream unbound of Pi-hole: Yes.
For a solitary unbound, you'd have to consult unbound's documentation.

That's a bit out of scope for Pi-hole ;) (click for more)

AFAIAAO, Happy Eyeballs was originally designed to forego unnecessary repeated IPv6 connection attempts when it is clear that there is no IPv6 connectivity on a dual stack host.

Furthermore, I guess it would depend on each software package whether it would take advantage of Happy Eyeballs or just use the usual way to establish a connection (probably involving getaddrinfo() on Linux-like systems).

If you experiment with this, I'd prepare for mixed results, depending on the software you use, i.e. a Chrome browser may be fine, but a streaming video-player may just hang in for seconds before retrying with a another IP.


This is independent of your upstream DNS resolver. The local domain name mapping to IP's happens in Pi-hole, which is prior to unbound. If Pi-hole knows the answer, nothing is forwarded to unbound for resolution.
For an upstream unbound of Pi-hole: Yes.

Pi-Hole talks to unbound

That's a bit out of scope for Pi-hole :wink:

Yeah I know, only need Pi-Hole to return multiple IP's and I can handle the rest.

click for more

Implemented it in the past, and it's alternating AAAA with A records kinda assume you might get multiple and have to take that into account. But most if not all of my applications will be browser based applications so I doubt that will be an issue.

pi@ph5b:~ $ man dnsmasq
[..]
       --host-record=<name>[,<name>....],[<IPv4-address>],[<IPv6-ad‐
       dress>][,<TTL>]
              Add A, AAAA and PTR records to the DNS. This  adds  one  or
              more  names  to  the  DNS with associated IPv4 (A) and IPv6
              (AAAA) records. A name may appear in more than one  --host-
              record  and  therefore  be  assigned more than one address.
              Only the first address creates a PTR record linking the ad‐
              dress to the name. This is the same rule as is used reading
              hosts-files.  --host-record options are  considered  to  be
              read  before host-files, so a name appearing there inhibits
              PTR-record creation if it appears in hosts-file  also.  Un‐
              like  hosts-files,  names are not expanded, even when --ex‐
              pand-hosts is in effect. Short and long names may appear in
              the   same  --host-record,  eg.   --host-record=laptop,lap‐
              top.thekelleys.org,192.168.0.1,1234::100

              If the time-to-live is given,  it  overrides  the  default,
              which  is  zero or the value of --local-ttl. The value is a
              positive integer and gives the time-to-live in seconds.
[..]
pi@ph5b:~ $ sudo nano /etc/dnsmasq.d/99-my-settings.conf
host-record=test.domain,10.10.10.10
host-record=test.domain,10.10.10.11
host-record=test.domain,10.10.10.12
pi@ph5b:~ $ pihole-FTL --test
dnsmasq: syntax check OK.
pi@ph5b:~ $ sudo service pihole-FTL reload
pi@ph5b:~ $
pi@ph5b:~ $ dig @localhost test.domain

; <<>> DiG 9.11.5-P4-5.1+deb10u5-Raspbian <<>> @localhost test.domain
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48472
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test.domain.                   IN      A

;; ANSWER SECTION:
test.domain.            2       IN      A       10.10.10.10
test.domain.            2       IN      A       10.10.10.11
test.domain.            2       IN      A       10.10.10.12

;; Query time: 3 msec
;; SERVER: ::1#53(::1)
;; WHEN: Wed Aug 04 04:40:53 CEST 2021
;; MSG SIZE  rcvd: 88
2 Likes

That works flawless and is probably also the cleanest solution😍. Thank you everyone for dropping in ideas, much appreciated

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.