os x 上 pdnsd 开机启动(LaunchDaemons)失败,求解,求原因, 谢谢

2016-05-23 19:35:28 +08:00
 vonsy
~/Library/LaunchAgents Per-user agents provided by the user.
/Library/LaunchAgents Per-user agents provided by the administrator.
/Library/LaunchDaemons System-wide daemons provided by the administrator.
/System/Library/LaunchAgents Per-user agents provided by Mac OS X.
/System/Library/LaunchDaemons System-wide daemons provided by Mac OS X.

添加到 LaunchDaemons 中,服务启不来.
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.pdnsd.plist
sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.pdnsd.plist

sudo plutil -lint homebrew.mxcl.pdnsd.plist // 这个检查结果 ok

权限,所有者改了, 可执行程序也改了(pdnsd)
sudo chown root /Library/LaunchDaemons/homebrew.mxcl.pdnsd.plist
sudo chmod 644 /Library/LaunchDaemons/homebrew.mxcl.pdnsd.plist

plist 试了以下两种种,都不行:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.pdnsd</string>
<key>OnDemand</key>
<false/>
<key>Program</key>
<string>/usr/local/sbin/pdnsd</string>
<key>ServiceDescription</key>
<string>pdnsd - a proxy DNS server with permanent caching</string>
</dict>
</plist>

******************************************************************************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.pdnsd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/pdnsd</string>
<string>--daemon</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

但是
1. 手工启动可以: /usr/local/sbin/pdnsd --daemon, 使用也正常
2. dnsmasq 能正常启动:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.dnsmasq</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/dnsmasq</string>
<string>--keep-in-foreground</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

这到底是为什么? 我只是想通过 tcp 解析 dns
2687 次点击
所在节点    Apple
7 条回复
JackBlack2006
2016-05-23 19:56:44 +08:00
sudo brew services start pdnsd
vonsy
2016-05-23 21:54:45 +08:00
@JackBlack2006 不行,使用 brew install pdnsd 重新装了也不行

sys-MacBook-Pro:~ fsy$ sudo brew services start pdnsd
Password:
Error: Formula `pdnsd` not installed, #plist not implemented or no plist file found
sys-MacBook-Pro:~ fsy$ sudo brew services list
Name Status User Plist
dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sys-MacBook-Pro:~ fsy$
JackBlack2006
2016-05-23 22:12:48 +08:00
你不是装了 dnsmasq 么,这一个够用了吧
JackBlack2006
2016-05-23 22:14:02 +08:00
贴 conf

没准你忘记改 pdnsd 端口了
vonsy
2016-05-23 22:40:15 +08:00
@JackBlack2006 dnsmasq 不支持 tcp 请求. 我想系统使用 dnsmasq(端口 53), dnsmasq 上游是 pdnsd(端口 1053)

现在就是 sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.pdnsd.plist 无法启动 eblt
手工直接 /usr/local/sbin/pdnsd --daemon 服务能启动,也能正常使用的.

/usr/local/etc/pdnsd.conf

global {
# debug = on; # /var/pdnsd/pdnsd.debug
perm_cache=10240; # 1MB cache
cache_dir="/usr/local/var/cache/pdnsd";
#run_as="nobody";
paranoid=on;
par_queries=5;
server_port = 1053;
server_ip = 127.0.0.1;
status_ctl = on;
query_method=tcp_only; # gfw don't pollute TCP query now
min_ttl=2h;
max_ttl=1w;
timeout=6;
# https://wiki.archlinux.org/index.php/Pdnsd#Performance_Settings_For_Home_Broadband_Users
neg_rrs_pol=on;
}

server {
label="Google Public DNS";
ip=8.8.8.8,8.8.4.4;
# root_server = on;
#uptest = ping;
uptest = none;
proxy_only=on;
purge_cache=off;
}

source {
owner=localhost;
# serve_aliases=on;
file="/etc/hosts";
}

rr {
name=localhost;
reverse=on;
a=127.0.0.1;
owner=localhost;
soa=localhost,root.localhost,42,86400,900,86400,86400;
}
Daniel65536
2016-05-24 00:32:49 +08:00
纯粹是 launchctl 的 plist 写错了,去读 https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html

两个 plist 都没指定什么时候执行 pdnsd ,你 service 启动时根本屁事都不会做。第二个 plist 用了 KeepAlive 就不要加--daemon ,否则启动了 pdnsd 之后 fork 两次成为 daemon , launchd 启动的 pdnsd 自己挂掉, KeepAlive 项会尝试再次启动 pdnsd 然后不断报错。

正确的 plist 照着 dnsmasq 的改就好:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl. pdnsd </string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/pdnsd </string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
tony1016
2016-05-24 09:22:37 +08:00
@JackBlack2006 brew 竟然还有这个功能,学习了

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

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

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

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

© 2021 V2EX