将dnsmasq的DHCP服务器限制为一个接口


Answers:


13

手册页解释了它相当不错。如果只是DHCP,而您不想在其上运行,wlan0则可以使用--no-dhcp-interface=wlan0。如果您根本不想dnsmasq进行监听,wlan0则可以使用--except-interface=wlan0

如果只希望dnsmasq监听,eth0则可以使用--interface=eth0


12

对于像我这样的人来说,他们困惑为什么为什么对所有接口仍然打开端口53,无论您使用哪种选项进行限制。还有另外一个选项需要打开。

-z, --bind-interfaces On systems which support it, dnsmasq binds the wildcard address, even when it is listening on only some interfaces. It then discards requests that it shouldn't reply to. This has the advantage of working even when interfaces come and go and change address. This option forces dnsmasq to really bind only the interfaces it is listening on. About the only time when this is useful is when running another nameserver (or another instance of dnsmasq) on the same machine. Setting this option also enables multiple instances of dnsmasq which provide DHCP service to run in the same machine.


正是这种事情很容易被忽略,但这是使其与其他DHCP解决方案(例如,在我的情况下为QNAP内部服务)一起工作的关键。有人应该把三个主要答案合并起来。这挽救了我的一天,谢谢
Danielo515 '19

11

这也可以从dnsmasq配置文件中获得,并记录在Simon Kelley的示例文件中,该文件位于http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq.conf.example

# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
#interface=
# Or you can specify which interface _not_ to listen on
#except-interface=
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.