dae*_*tar 17 domain-name-system resolv.conf mac-osx
我已经安装、配置了 DNS 服务器(Dnsmasq 的本地实例),它可以根据需要解析为 localhost,一切正常。
当我离线时,它停止工作,因为 OS X 清空了 resolv.conf 的内容并忽略了反映此文件中更改的尝试。
任何想法,即使在离线时如何配置 DNS?
类似问题(未解决):http : //blog.steamshift.com/geek/leopard-lookupd-and-local-web-development-sites
主要动机是简化使用子域作为帐户密钥的 RoR 应用程序的开发。并且您不能在 /etc/hosts 中使用 127.0.0.1 *.yourapp.local。有些人为它注册了域 smackaho.st 和 srt DNS,例如 .smackaho.st 在 127.0.0.1 但仍然无法在离线工作时使用它。
编辑:尝试过 scutil 命令,但如果离线,您似乎可以更改 DNS
注意:当您关闭所有接口时,您无法在 Pref 中设置 DNS 服务器。控制板。
gun*_*uns 29
我也喜欢在我的本地机器上使用 Dnsmasq,我也有这个问题。这是解决方案:
来自man 5 resolver:
The configuration for a particular client may be read from a file
having the format described in this man page. These are at present
located by the system in the /etc/resolv.conf file and in the files
found in the /etc/resolver directory.
Run Code Online (Sandbox Code Playgroud)
/etc/resolver/默认情况下不存在;您必须自己创建它。
同样来自手册页:
domain
Domain name associated with this resolver configuration. This
option is normally not required by the Mac OS X DNS search system
when the resolver configuration is read from a file in the
/etc/resolver directory. In that case the file name is used as the
domain name.
Run Code Online (Sandbox Code Playgroud)
因此,如果您希望将顶级域的所有 dns 查询dev路由到本地名称服务器,您可以:
# mkdir /etc/resolver
# echo 'nameserver 127.0.0.1' > /etc/resolver/dev
Run Code Online (Sandbox Code Playgroud)
configd不会更改 中的文件/etc/resolver/,因此此设置将通过网络更改和重新启动保持不变。
不幸的是,从 OS X Lion 开始,scutil
--dns当没有活动接口时,顶级解析器(如 所示)会消失:
# scutil --dns # Online
DNS configuration
resolver #1
nameserver[0] : 127.0.0.1
...
resolver #8
domain : dev
nameserver[0] : 127.0.0.1
# scutil --dns # Offline
DNS configuration
resolver #1
...
resolver #8
domain : dev
nameserver[0] : 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
请注意,解析器 #1 为空,但 /etc/resolver 派生的名称服务器条目仍然存在。
事实证明,由于您可以直接在 /etc/resolver/ 文件中指定解析器域,因此指定特殊的 Internet 根域.
会导致创建一个如下所示的全局解析器条目:
resolver #8
nameserver[0] : 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
现在所有 DNS 查询都路由到本地主机,即使在离线时也是如此。
当然,您仍然需要使用类似 dnsmasq 的 --address 选项将您选择的域解析为 127.0.0.1:
# dnsmasq --address=/dev/127.0.0.1
Run Code Online (Sandbox Code Playgroud)
networksetup -setdnsservers 以太网 127.0.0.1
网络设置-setdnsservers Wi-Fi 127.0.0.1
...
名称服务器 127.0.0.1
领域 。
参见 http://opensource.apple.com/source/configd/configd-395.11/dnsinfo/dnsinfo_flatfile.c
| 归档时间: |
|
| 查看次数: |
22805 次 |
| 最近记录: |