强制 dnsmasq 为 DHCP 绑定接口

强制 dnsmasq 为 DHCP 绑定接口

我想在两个接口上使用带有两个配置的 dnsmasq,这两个接口应该在本地绑定。如果你阅读手册页,它看起来interface=wlan0 bind-interfaces应该可以解决问题。但它总是将 dhcp 服务器绑定到所有接口:

udp        0      0 192.168.101.1:53        0.0.0.0:*                           0          7410711     22333/dnsmasq   
udp        0      0 0.0.0.0:67              0.0.0.0:*                           0          7410708     22333/dnsmasq 

配置:

interface=wlan0
except-interface=lo
except-interface=wlan0_0
no-dhcp-interface=wlan0_0
dhcp-range=interface:wlan0,192.168.101.2,192.168.101.255,60m
bind-interfaces

命令行:dnsmasq -C /etc/dnsmasq.wlan0.conf -z

很多选项在理论上应该是多余的,但在实践中它仍然具有约束力0.0.0.0:67

答案1

您可以使用一个实例完成所有想要做的事情。这是基于我使用过的配置的示例。

# DHPC ranges set tag
dhcp-range=set:able,192.168.20.10,192.168.20.100,255.255.255.0,48h
dhcp-range=set:baker,192.168.30.10,192.168.30.100,255.255.255.0,192h

# Tag dependent options
dhcp-option=able,3,192.168.20.1           # Router
dhcp-option=able,15,able.example.com      # Domain
dhcp-option=baker,3,192.168.20.1          # Router
dhcp-option=baker,15,baker.example.com    # Domain

# Common settings
dhcp-option=6,192.168.20.2,192.168.30.2   # DNS servers
dhcp-option=19,0                          # Option ip-forwarding off
dhcp-option=20,0                          # Source routing off
dhcp-option=27,1                          # All sub-nets are local
dhcp-option=31,0                          # Router Discovery off
dhcp-option-force=42,192.168.20.5         # NTP time servers
dhcp-option=119,able.example.com,example.com # Search List

手册页中介绍了这一点。

相关内容