我有一个networking,我运行dnsmasq做DHCP和DNS。 我的networking有几个客户端,每个客户端都需要与主机进行通信(他们使用dnsmasq进行DNS查询)。 我现在想要在同一个networking上运行几个主/客户组,并且我希望能够轻松地configuration哪个客户与哪个主服务器相关联。
是否有可能configurationdnsmasq这样会给不同的客户端一个特定的DNS查询不同的响应? 例如,如果10.0.2.23查询master我想要的结果是10.0.3.1 。 但是,如果10.0.2.24查询master我想要的结果是10.0.3.2 。
我知道我可以通过在每个客户端的/etc/hosts文件中创buildmaster条目来实现这一点,但是如果这些信息全部在一个单独的configuration文件中(例如/etc/dnsmasq.d/masterclient.conf )
TL; DR:显性比隐性好
您可能还需要确保您在networking上运行的任何诊断程序都能够揭示每对成员之间的连接。
如果dnsmasq同时执行dns和dhcp,那么它很容易解决你的“每个客户端都知道他们的主”的问题,并且validation正确的设置是否可能 – 通过不让dnsmasq根据谁查询做出不同的响应。
我build议你确保每个客户端都要求它的主人具体地通过使其组成其完全合格的域名的一部分:
# make sure your dhcp clients use dnsmasq as dns & split them in groups # (you probably already do that baes on either mac or subnet) dhcp-range=set:group1,10.0.2.0,10.0.2.23,255.255.255.0,4h dhcp-range=set:group2,10.0.2.24,10.0.2.50,255.255.255.0,4h dhcp-otion=option:dns-server,0.0.0.0 # based on tags, give them a dns search domain dhcp-option=tag:group1,option:domain-search,pair1.local dhcp-option=tag:group2,option:domain-search,pair2.local # making the respective master address known to them address=/master.pair1.local/10.0.3.1 address=/master.pair2.local/10.0.3.2
有一些方法可以根据不同的参数决定哪个客户端在哪个组中。 这取决于什么决定了哪一个客户端应该是我的示例在dhcp-range分裂可能是足够或完全不适当的。
警告:将客户端重新configuration到不同的组只能按照DHCP租用时间来完成 – 这比dns TTL更不灵活。