SRV records in Pi-hole

EDIT: I altered below bc the target should not contain an IP but a domain name instead (with its own A or AAAA records to resolve to an IP address).

A bit late and that link of mine is a bit outdated because Pi-hole doesnt set 127.0.0.1 anymore as a local resolver in the file /etc/resolv.conf.
For posterity:

dehakkelaar@ph6b:~$ man dnsmasq
[..]
       -W,        --srv-host=<_service>.<_prot>.[<domain>],[<tar-
       get>[,<port>[,<priority>[,<weight>]]]]
              Return a SRV DNS record. See RFC2782  for  details.
              If  not supplied, the domain defaults to that given
              by --domain.  The default for the target domain  is
              empty,  and the default for port is one and the de-
              faults for weight and priority are zero. Be careful
              if transposing data from BIND zone files: the port,
              weight and priority numbers are in a different  or-
              der.  More  than  one  SRV  record for a given ser-
              vice/domain is allowed,  all  that  match  are  re-
              turned.
dehakkelaar@ph6b:~$ sudo nano /etc/dnsmasq.d/99-my-settings.conf
srv-host=_http._tcp.home.web,target_domain,20080,10,1
dehakkelaar@ph6b:~$ pihole-FTL --test
dnsmasq: syntax check OK.
dehakkelaar@ph6b:~$ sudo systemctl reload pihole-FTL.service
dehakkelaar@ph6b:~$
dehakkelaar@ph6b:~$ nslookup -type=srv _http._tcp.home.web 127.0.0.1
Server:         localhost
Address:        127.0.0.1#53

_http._tcp.home.web     service = 10 1 20080 target_domain.
dehakkelaar@ph6b:~$ dig +short @127.0.0.1 _http._tcp.home.web srv
10 1 20080 target_domain.

As an example how its used to load balance APT mirrors (round robin):

dehakkelaar@ph6b:~$ dig +short _http._tcp.apt.xbian.org srv
10 1 80 xbian-apt.mirrorservice.org.
10 1 80 apt.xbian.org.
10 1 80 apt1.xbian.org.
1 Like