| 我们选择在 /Library/LaunchAgents/ 目录下创建 coredns.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>coredns</string>     <key>ProgramArguments</key>     <array>       <string>/usr/local/bin/coredns</string>       <string>-conf</string>       <string>/usr/local/etc/Corefile</string>     </array>     <key>StandardOutPath</key>     <string>/var/log/coredns.stdout.log</string>     <key>StandardErrorPath</key>     <string>/var/log/coredns.stderr.log</string>     <key>KeepAlive</key>     <true/>     <key>RunAtLoad</key>     <true/>   </dict> </plist> 
 设置开机自动启动 coredns: $ sudo launchctl load -w /Library/LaunchAgents/coredns.plist 
 查看服务: $ sudo launchctl list|grep coredns  61676   0   coredns 
 $ sudo launchctl list coredns  {     "StandardOutPath" = "/var/log/coredns.stdout.log";     "LimitLoadToSessionType" = "System";     "StandardErrorPath" = "/var/log/coredns.stderr.log";     "Label" = "coredns";     "TimeOut" = 30;     "OnDemand" = false;     "LastExitStatus" = 0;     "PID" = 61676;     "Program" = "/usr/local/bin/coredns";     "ProgramArguments" = (         "/usr/local/bin/coredns";         "-conf";         "/usr/local/etc/Corefile";     ); }; 
 查看端口号: $ sudo ps -ef|egrep -v grep|grep coredns      0 81819     1   0  2:54下午 ??         0:04.70 /usr/local/bin/coredns -conf /usr/local/etc/Corefile      $ sudo lsof -P -p 81819|egrep "TCP|UDP"  coredns 81819 root    5u    IPv6 0x1509853aadbdf853      0t0     TCP *:5302 (LISTEN) coredns 81819 root    6u    IPv6 0x1509853acd2f39ab      0t0     UDP *:5302 coredns 81819 root    7u    IPv6 0x1509853aadbdc493      0t0     TCP *:53 (LISTEN) coredns 81819 root    8u    IPv6 0x1509853acd2f5a4b      0t0     UDP *:53 coredns 81819 root    9u    IPv6 0x1509853ac63bfed3      0t0     TCP *:5301 (LISTEN) coredns 81819 root   10u    IPv6 0x1509853acd2f5d03      0t0     UDP *:5301 
 大功告成,现在你只需要将系统的 DNS IP 设置为 127.0.0.1 就可以了。 (编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |