5

Is there something like /etc/hosts file for SRV records? I would like my Alpine Linux server to find the value of _xmpp-server._tcp SRV record locally.

0

1 Answer 1

3

Linux does not have a built in method for that, you should look into dnsmasq and setup a lightweight DNS resolver, first install it

apk add dnsmasq

then we create a configuration file for example here /etc/dnsmasq.conf

put this inside

# Use the following DNS servers as the upstream servers
server=8.8.8.8
server=8.8.4.4

# Define your local SRV record
srv-host=_xmpp-server._tcp.example.com,server.example.com,5269,0,5

# Replace "example.com" with your domain and "server.example.com" with your server's hostname

then we start it

rc-service dnsmasq start
rc-update add dnsmasq

and now you can configure your server to use our DNS resolver, add this at the top of /etc/resolv.conf

nameserver 127.0.0.1
4
  • Note that on modern distros, /etc/resolv.conf is often managed by NetworkManager or systemd which means changes will be overwritten on the next reboot/network change. Apr 9, 2023 at 16:14
  • @Ginnungagap Though you can generally override that in turn (or just make your changes and mark the file immutable, though things may complain vociferously about this in your log files). Apr 9, 2023 at 22:15
  • @Ginnungagap: You could...configure the NetworkManager or systemd-networkd connection profiles to use 127.0.0.1 as the DNS server? Apr 10, 2023 at 6:00
  • Yes I was just warning against editing /etc/resolv.conf directly. I'm not saying it's unfeasible, just that the current will likely work temporarily only. Apr 10, 2023 at 8:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .