使用 DNSMasq 查找 LAN 上的主机名

使用 DNSMasq 查找 LAN 上的主机名

我在 DD-WRT 路由器上运行 DNSMasq 作为 DHCP 和 DNS 服务器。我原以为 DNSMasq 会自动将其在 DHCP 中注册的主机添加到 DNS 服务器,但我的网络上有几台机器 DNS 服务器声称找不到它们。我还需要做什么?

DNSMasq 配置(/tmp/dnsmasq.conf):

interface=br0
resolv-file=/tmp/resolv.dnsmasq
all-servers
domain=domain
dhcp-leasefile=/tmp/dnsmasq.leases
dhcp-lease-max=144
dhcp-option=lan,3,0.0.0.1
dhcp-authoritative
dhcp-range=lan,0.0.0.100,0.0.0.200,255.255.0.0,1440m
stop-dns-rebind

dhcp-option= option:dns-server, 0.0.0.1 # DHCP option 006

server = 4.2.2.3
server = 4.2.2.4
server = 4.2.2.1
server = 4.2.2.2

DNSMasq租约文件 (/tmp/dnsmasq.leases):

86400 00:00:00:00:00:01 0.0.0.101 host_fail *
86400 00:00:00:00:00:02 0.0.0.102 host_succeed *

/nslookup结果:

root@dd-wrt:~# ping host_succeed
PING host_succeed (0.0.0.102): 56 data bytes
64 bytes from 0.0.0.102: seq=0 ttl=64 time=2.138 ms
64 bytes from 0.0.0.102: seq=1 ttl=64 time=0.892 ms

--- host_succeed ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.892/1.515/2.138 ms
root@dd-wrt:~# ping host_fail
root@dd-wrt:~# nslookup host_succeed
Server:    0.0.0.1
Address 1: 0.0.0.1 dd-wrt.domain

Name:      host_succeed
Address 1: 0.0.0.102 host_succeed
root@dd-wrt:~# nslookup host_fail
Server:    0.0.0.1
Address 1: 0.0.0.1 dd-wrt.domain

root@dd-wrt:~# cat /etc/hosts 
127.0.0.1   localhost
0.0.0.1     dd-wrt.domain
root@dd-wrt:~# cat /etc/resolv.conf 
search isp.net
search domain
nameserver 0.0.0.1

两者之间有什么不同主机失败主机成功?我对此表示怀疑,但客户端是否需要改变?nslookup将任何数据传输到主机本身(而不仅仅是 DNS)?

我之前遇到过我的客户端没有发送主机名但我相信路由器和租约现在可以确认我的客户端做得正确。

我需要进行哪些更改才能确保 DNSMasq 可以为其给定的 DHCP 租约的这些主机提供 DNS 请求?

答案1

我遇到的客户端是 XBian Raspberry Pi,之后进行了后续更新一些错误修正看来问题已经解决了。

相关内容