是否可以在linux中创建本地SRV记录?

Nav*_*777 5 linux internal-dns linux-networking srv-record

有类似/etc/hosts档案之类的SRV记录吗?我希望我的 Alpine Linux 服务器能够_xmpp-server._tcp SRV在本地找到记录的值。

小智 3

Linux 没有内置方法,您应该研究dnsmasq并设置一个轻量级 DNS 解析器,首先安装它

apk add dnsmasq
Run Code Online (Sandbox Code Playgroud)

然后我们在这里创建一个配置文件/etc/dnsmasq.conf

把这个放进去

# 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
Run Code Online (Sandbox Code Playgroud)

然后我们开始它

rc-service dnsmasq start
rc-update add dnsmasq
Run Code Online (Sandbox Code Playgroud)

现在您可以配置您的服务器以使用我们的 DNS 解析器,将其添加到顶部/etc/resolv.conf

nameserver 127.0.0.1
Run Code Online (Sandbox Code Playgroud)