我的dnsmasq已配置:
- 在主机“ rtfm.lan”上
- 域“ lan”
- 有些DHCP预设包含主机名
通过DHCP注册的所有“ * .lan”主机都可以正常解析:dnsmasq知道将哪些IP分配给了哪些主机名。但是,从/ etc / hosts中读取“ rtfm.lan”并解析为127.0.0.1。
我可以防止dnsmasq读取/ etc / hosts并手动添加地址:
no-hosts
address=/rtfm.lan/192.168.1.2
但这并不灵活:如果有一天我决定更改我的IP,我还必须在dnsmasq.conf中进行更改。
如何告诉dnsmasq使用其真实IP的本地主机名?
以防万一..这是我的DNSmasq配置:
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
# Read resolv.conf serially
strict-order
#==========[ NAMESERVER ]==========#
# Cache size
cache-size=4096
# Don't read /etc/hosts
no-hosts
# Read additional hosts-file (not only /etc/hosts) to add entries into DNS
addn-hosts=/etc/hosts-dnsmasq
# Auto-append <domain> to simple entries in hosts-file
expand-hosts
#=== HOSTNAME OVERRIDES
address=/localhost/127.0.0.1 # *.localhost => 127.0.0.1
#==========[ DHCP ]==========#
# Enable for the local network?
dhcp-authoritative
# Tell MS Windows to release a lease on shutdown
dhcp-option=vendor:MSFT,2,1i
#=== DHCP
# Domain name
domain=lan
# DNS-resolve hosts in these domains ONLY from /etc/hosts && DHCP leases
local=/lan/
# DHCP range & lease time
dhcp-range=192.168.1.70,192.168.1.89,24h
# Default route
dhcp-option=3,192.168.1.1
#=== FIXED LEASES
# LAN MY HOSTS
dhcp-host=00:23:54:5d:27:fa, rtfm.lan, 192.168.1.2
dhcp-host=00:23:54:5d:27:fb, rtfm.lan, 192.168.1.2
dhcp-host=c8:0a:a9:45:f1:03, 00:1e:64:9e:e9:5e, wtf.lan, 192.168.1.3