我只想使用 dnsmasq 将所有 dns 请求转发到 google 的 dns 服务器并禁用 dhcp...
我怎样才能达到这个结果?
答案1
dnsmasq 默认禁用 dhcp 服务器。要启用它,您必须取消注释/etc/dnsmasq.conf
要将所有请求转发到 208.67.222.222,只需添加(不触及 dnsmasq 配置)/etc/resolv.conf
:
nameserver 127.0.0.1
# In order to configure dnsmasq to act as cache for the host on which it
# is running, put [as the first line] "nameserver 127.0.0.1" in /etc/resolv.conf to force
# local processes to send queries to dnsmasq. [...]
# dnsmasq is smart enough to ignore this line and forward all queries appropriately,
# while all other applications will send all their queries to dnsmasq.
nameserver 208.67.222.222
就是这样 :)
答案2
只需注释掉 dnsmasq.conf 文件中与 dhcp 相关的行,然后重新启动 dnsmasq。
答案3
要禁用 DHCP,请注释掉 dnsmaq.conf 文件中的所有“dhcp-range”设置,并删除启动“dnsmasq”可执行程序/守护进程时使用的所有“--dhcp-range”命令行选项。
示例文件名:/etc/dnsmasq.conf
注释掉的行示例:
#dhcp-range=192.168.0.50,192.168.0.150,12h
来源:dnsmasq 文档
答案4
在Ubuntu [18.04]:注释掉所有
dhcp-*
dhcp-range=
两个文件中的行:
/etc/dnsmasq.d/dhcp-settings
和
/etc/dnsmasq.conf
然后只需重新启动服务:
sudo systemctl restart dnsmasq