我想问一个有关dnsmasq DNS服务器configuration的问题。 我知道这样的configuration选项“听地址”。 但即使我将此选项设置为“listen-address = 127.0.0.1”,dnsmasq仍在内部127.0.0.1:53和外部192.168.xx:53端打开端口。
所以我想问一下,是否可以configurationdnsmasq,以便为localhost(127.0.0.1)打开端口53,例如对于MySQL数据库是可能的。
# Configuration file for dnsmasq. port=53 proxy-dnssec no-resolv no-poll server=127.0.0.1#[some port here] server=127.0.0.1#[some another port here] listen-address=127.0.0.1 no-hosts
我不得不在configuration文件中添加“bind-interfaces”,这样interface和listen-address才能达到预期效果。 例如:
listen-address=127.0.0.1 interface=lo bind-interfaces
这将只有在本地主机上收听的预期效果。 我遇到了一些问题,因为我在服务器的公共IP上运行了一个公共dns(只parsing了我自己的域),但是我也想在本地主机上运行dnsmasq。 所以,如果我删除“绑定接口”,我会得到“dnsmasq:无法创build监听套接字端口53:地址已经在使用”,因为它试图侦听公共IP。
是的,你可以这么做
dnsmasq手册页说这个关于–interface参数:
-i, --interface=<interface name> Listen only on the specified interface(s). Dnsmasq automatically adds the loopback (local) interface to the list of interfaces to use when the --interface option is used. If no --interface or --listen-address options are given dnsmasq listens on all available inter‐ faces except any given in --except-interface options. IP alias interfaces (eg "eth1:0") cannot be used with --interface or --except- interface options, use --listen-address instead. A simple wildcard, consisting of a trailing '*', can be used in --interface and --except-interface options.
在大多数系统上,localhost / 127.0.0.1的接口名称默认为lo 。
你可以把它放在你的configuration文件中,像这样
interface=lo
或者像这样在命令行中指定它
dnsmasq --interface=lo