V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
hzqim
V2EX  ›  问与答

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

  •  
  •   hzqim · 2015-06-25 14:36:59 +08:00 · 3539 次点击
    这是一个创建于 3199 天前的主题,其中的信息可能已经有所发展或是发生改变。
    目前知道以下方法,一个顶级域写一个 address
    如:
    address=/.com/127.0.0.1
    address=/.net/127.0.0.1

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

    谢谢。
    8 条回复    2015-06-25 16:02:42 +08:00
    ChoateYao
        1
    ChoateYao  
       2015-06-25 14:54:41 +08:00   ❤️ 1
    设置网卡DNS为127.0.0.1
    设置DNSMASQ的resolv-file的路径,
    resolv-file 文件内容为上级DNS
    比如
    nameserver=8.8.8.8
    ChoateYao
        2
    ChoateYao  
       2015-06-25 14:55:05 +08:00   ❤️ 1
    这样才对:nameserver 8.8.8.8
    hzqim
        3
    hzqim  
    OP
       2015-06-25 15:04:10 +08:00
    @ChoateYao 谢谢您的回答,请问您指的是 /etc/resolv.conf 吗?
    这个网卡 DNS 为 127.0.0.1 只能说 DNS 架设在本地吧,
    和域名解析到 127.0.0.1 是等效吗?
    ChoateYao
        4
    ChoateYao  
       2015-06-25 15:08:03 +08:00   ❤️ 1
    是的。
    ChoateYao
        5
    ChoateYao  
       2015-06-25 15:09:31 +08:00   ❤️ 1
    难道你不是想要本地DNS缓存吗?
    lk09364
        6
    lk09364  
       2015-06-25 15:09:39 +08:00   ❤️ 3
    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
        7
    LazyZhu  
       2015-06-25 15:43:27 +08:00   ❤️ 1
    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
        8
    hzqim  
    OP
       2015-06-25 16:02:42 +08:00
    @lk09364 谢谢!
    @LazyZhu 大神,谢谢,从 hostloc 到 v2ex ,总能看到您无私的身影!!!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3230 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 14:19 · PVG 22:19 · LAX 07:19 · JFK 10:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.