dnsmasq配置类似白名单操作?

新手上路,请多包涵

dnsmasq如何配置实现我已有配置的域名最先走指定的解析ip,已配置的域名中走已配置的dns,已配置的域名以上解析不通才走114.114.114.114。而且其他域名无法执行解析操作。类似白名单功能

阅读 2.2k
2 个回答

在 dnsmasq 配置文件(/etc/dnsmasq.conf)这样配置一下就好了:

address=/example.com/1.2.3.4
server=/example2.com/8.8.8.8
server=114.114.114.114
server=/.#/

单个Dnsmasq服务可能无法实现。


为单个域名指定DNS

-S, --local, --server=[/[<domain>]/[domain/]][<server>[#<port>]]@<interface>]
Specify upstream servers directly. Setting this flag does not suppress reading of /etc/resolv.conf, use --no-resolv to do that. If one or more optional domains are given, that server is used only for those domains and they are queried only using the specified server. This is intended for private nameservers: if you have a nameserver on your network which deals with names of the form xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag --server=/internal.thekelleys.org.uk/192.168.1.1 will send all queries for internal machines to that nameserver, everything else will go to the servers in /etc/resolv.conf.

例子

server=/example.com/1.2.3.4

要按顺序解析

-o, --strict-order
By default, dnsmasq will send queries to any of the upstream servers it knows about and tries to favour servers that are known to be up. Setting this flag forces dnsmasq to try each query with each server strictly in the order they appear in /etc/resolv.conf

所以你需要配置Dnsmasq将指定域名的DNS指向另一个DNS服务器(例如另一个Dnsmasq服务),然后在那个DNS服务器上设置DNS查询的顺序。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题