V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
vonsy
V2EX  ›  Apple

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

  •  
  •   vonsy · 2016-05-23 19:35:28 +08:00 · 2774 次点击
    这是一个创建于 3108 天前的主题,其中的信息可能已经有所发展或是发生改变。
    ~/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
    第 1 条附言  ·  2016-05-26 17:59:35 +08:00
    无法启动的原因找到了
    pdnsd 配置文件 owner 使用 root, /usr/local/etc/pdnsd.conf

    现在服务自启动正常. 运行正常. 不过使用 1 楼的 brew services list 还是无法显示 pdnsd 服务.
    7 条回复    2016-05-24 09:22:37 +08:00
    JackBlack2006
        1
    JackBlack2006  
       2016-05-23 19:56:44 +08:00
    sudo brew services start pdnsd
    vonsy
        2
    vonsy  
    OP
       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
        3
    JackBlack2006  
       2016-05-23 22:12:48 +08:00
    你不是装了 dnsmasq 么,这一个够用了吧
    JackBlack2006
        4
    JackBlack2006  
       2016-05-23 22:14:02 +08:00
    贴 conf

    没准你忘记改 pdnsd 端口了
    vonsy
        5
    vonsy  
    OP
       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
        6
    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
        7
    tony1016  
       2016-05-24 09:22:37 +08:00
    @JackBlack2006 brew 竟然还有这个功能,学习了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1941 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 16:22 · PVG 00:22 · LAX 08:22 · JFK 11:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.