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

Del*_*ani 13 dnsmasq

我如何配置dnsmasq只分配地址eth0,而不是wlan0

小智 15

对于那些喜欢我的人来说,为什么端口 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(v6) 端口没有影响,即使使用“no-dhcp-interface”、“interface”等。我仍然看到“*:67”和“*:547”。(FreeBSD 上的版本“2.82”;也许这是一个回归。) (2认同)

Whe*_*ice 14

手册页解释了它相当不错。如果它只是您不想运行的 DHCP,wlan0那么您可以使用--no-dhcp-interface=wlan0. 如果您根本不想让 dnsmasq 收听,wlan0那么您可以使用--except-interface=wlan0.

如果您只想让 dnsmasq 收听,eth0那么您可以使用--interface=eth0.


Ste*_*ski 12

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

# 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=
Run Code Online (Sandbox Code Playgroud)