如何使用dnsmasq配置没有IPv6 / MX记录的本地域?

时间:2019-04-14 17:54:05

标签: dnsmasq

我使用dnsmasq服务器管理产品中的域列表。

我用这样的主机进行配置。 --addn-hosts=/etc/dnsmasq.d/hosts/service

cat /etc/dnsmasq.d/hosts/service

192.168.190.100 test.product.com

并且在产品的另一部分中,我必须向该域发出http请求。

我看起来像这样,cat http_get.py

import requests
import sys

URL = "http://test.product.com"
r = requests.get(url = URL, timeout=1)
data = r.json()
print data

time python http_get.py一起运行时,它几乎用10s来请求dns。

我已经用tcpdump分析了dns请求。

它表明它发出两种类型的DNS请求。

22:48:06.990049 IP l2.47857 > l2.domain: 18996+ A? test.product.com. (29)
22:48:06.990241 IP l2.47857 > l2.domain: 19787+ AAAA? test.product.com. (29)
...
22:48:11.994835 IP l2.47857 > l2.domain: 18996+ A? test.product.com. (29)
22:48:11.995081 IP l2.47857 > l2.domain: 19787+ AAAA? test.product.com. (29)

我不需要AAAA(IPv6)类型的请求。它表明它在2次尝试中挂了将近10秒。

如何在/etc/dnsmasq.d/hosts/service文件中进行配置?

我从产品中观察到MX的另一种请求test.product.com。它像AAAA(IPv6)请求一样挂起。

欢迎提出任何建议。非常感谢!

1 个答案:

答案 0 :(得分:0)

使用内置的虚拟DNS服务器并在/etc/hosts中配置记录。

192.168.190.100 test.product.local

并且在做所有事情时都要牢记标准。 请勿使用test.product.com并使用专门用于本地或测试用途的TLD(.local.test)。