dnsmasq 怎样高效地将所有域名解析到 127.0.0.1

2015-06-25 14:36:59 +08:00
 hzqim
目前知道以下方法,一个顶级域写一个 address
如:
address=/.com/127.0.0.1
address=/.net/127.0.0.1

可顶级域不单止这两个,一个个写起来,费时费力还有漏网之鱼,是否有更简单的定义法?

谢谢。
3548 次点击
所在节点    问与答
8 条回复
ChoateYao
2015-06-25 14:54:41 +08:00
设置网卡DNS为127.0.0.1
设置DNSMASQ的resolv-file的路径,
resolv-file 文件内容为上级DNS
比如
nameserver=8.8.8.8
ChoateYao
2015-06-25 14:55:05 +08:00
这样才对:nameserver 8.8.8.8
hzqim
2015-06-25 15:04:10 +08:00
@ChoateYao 谢谢您的回答,请问您指的是 /etc/resolv.conf 吗?
这个网卡 DNS 为 127.0.0.1 只能说 DNS 架设在本地吧,
和域名解析到 127.0.0.1 是等效吗?
ChoateYao
2015-06-25 15:08:03 +08:00
是的。
ChoateYao
2015-06-25 15:09:31 +08:00
难道你不是想要本地DNS缓存吗?
lk09364
2015-06-25 15:09:39 +08:00
http://serverfault.com/questions/351108/using-dnsmasq-to-resolve-all-hosts-to-the-same-address

> As the dnsmasq manual says …
>
> … just use # for a wildcard:
>
> address=/#/192.168.2.1
LazyZhu
2015-06-25 15:43:27 +08:00
http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
"The domain specification works in the same was as for --server, with the additional facility that /#/ matches any domain. Thus --address=/#/1.2.3.4 will always return 1.2.3.4 for any query not answered from /etc/hosts or DHCP and not sent to an upstream nameserver by a more specific --server directive. "
hzqim
2015-06-25 16:02:42 +08:00
@lk09364 谢谢!
@LazyZhu 大神,谢谢,从 hostloc 到 v2ex ,总能看到您无私的身影!!!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/201078

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX