如何使用dnsmasq配置多网口的dhcp和dns

最近在FreeBSD11.2下配置dhcp和dns服务,机器具有多个网口,上网查了很多资料,参考了如下几篇文章,有些是正确的,有些在我的环境下验证是错误的,特地写出来,供大家参考

Dnsmasq域名解析系统安装配置
dnsmasq详解&手册
dnsmasq dhcp服务多网卡多地址池

废话少说,上菜

addn-hosts=/usr/local/etc/dnsmasq.hosts
port=53
cache-size=500
domain=tianzhi-hotel.local
localise-queries
bind-interfaces

interface=em2
listen-address=192.168.5.254
dhcp-range=192.168.5.10,192.168.5.20,255.255.255.0,3600s
dhcp-option=option:router,0.0.0.0
dhcp-option=option:dns-server,0.0.0.0
dhcp-option=option:ntp-server,0.0.0.0

interface=em3
listen-address=192.168.6.254
dhcp-range=192.168.6.10,192.168.6.20,255.255.255.0,3600s
dhcp-option=option:router,0.0.0.0
dhcp-option=option:dns-server,0.0.0.0
dhcp-option=option:ntp-server,0.0.0.0

上述配置中带有dhcp字样的与dhcp有关,其余只与dns有关;
测试过程中发现,要实现不同网卡获取到的配置与该网段配置一致,最关键的部分为0.0.0.0,如果把这一部分配置为listen-address 值一致,客户机上得到的网关和dns是错误的,随机匹配到其它网卡的配置上

你可能感兴趣的:(运维)