加入收藏 | 设为首页 | 会员中心 | 我要投稿 衡阳站长网 (https://www.0734zz.cn/)- 数据集成、设备管理、备份、数据加密、智能搜索!
当前位置: 首页 > 站长资讯 > 外闻 > 正文

使用 CoreDNS 来应对 DNS 污染

发布时间:2019-04-02 14:20:11 所属栏目:外闻 来源:yangcs
导读:CoreDNS 是新晋的 CNCF 孵化项目,前几天已经从 CNCF 正式毕业,并正式成为 Kubernetes 的 DNS 服务器。CoreDNS 的目标是成为 cloud-native 环境下的 DNS 服务器和服务发现解决方案,即: Our goal is to make CoreDNS the cloud-native DNS server and se

我们选择在 /Library/LaunchAgents/ 目录下创建 coredns.plist 文件,内容如下:

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
  3. <plist version="1.0"> 
  4.   <dict> 
  5.     <key>Label</key> 
  6.     <string>coredns</string> 
  7.     <key>ProgramArguments</key> 
  8.     <array> 
  9.       <string>/usr/local/bin/coredns</string> 
  10.       <string>-conf</string> 
  11.       <string>/usr/local/etc/Corefile</string> 
  12.     </array> 
  13.     <key>StandardOutPath</key> 
  14.     <string>/var/log/coredns.stdout.log</string> 
  15.     <key>StandardErrorPath</key> 
  16.     <string>/var/log/coredns.stderr.log</string> 
  17.     <key>KeepAlive</key> 
  18.     <true/> 
  19.     <key>RunAtLoad</key> 
  20.     <true/> 
  21.   </dict> 
  22. </plist> 

设置开机自动启动 coredns:

  1. $ sudo launchctl load -w /Library/LaunchAgents/coredns.plist 

查看服务:

  1. $ sudo launchctl list|grep coredns  
  2. 61676   0   coredns 
  1. $ sudo launchctl list coredns 
  2.  
  3.     "StandardOutPath" = "/var/log/coredns.stdout.log"; 
  4.     "LimitLoadToSessionType" = "System"; 
  5.     "StandardErrorPath" = "/var/log/coredns.stderr.log"; 
  6.     "Label" = "coredns"; 
  7.     "TimeOut" = 30; 
  8.     "OnDemand" = false; 
  9.     "LastExitStatus" = 0; 
  10.     "PID" = 61676; 
  11.     "Program" = "/usr/local/bin/coredns"; 
  12.     "ProgramArguments" = ( 
  13.         "/usr/local/bin/coredns"; 
  14.         "-conf"; 
  15.         "/usr/local/etc/Corefile"; 
  16.     ); 
  17. }; 

查看端口号:

  1. $ sudo ps -ef|egrep -v grep|grep coredns 
  2.  
  3.     0 81819     1   0  2:54下午 ??         0:04.70 /usr/local/bin/coredns -conf /usr/local/etc/Corefile 
  4.      
  5. $ sudo lsof -P -p 81819|egrep "TCP|UDP" 
  6.  
  7. coredns 81819 root    5u    IPv6 0x1509853aadbdf853      0t0     TCP *:5302 (LISTEN) 
  8. coredns 81819 root    6u    IPv6 0x1509853acd2f39ab      0t0     UDP *:5302 
  9. coredns 81819 root    7u    IPv6 0x1509853aadbdc493      0t0     TCP *:53 (LISTEN) 
  10. coredns 81819 root    8u    IPv6 0x1509853acd2f5a4b      0t0     UDP *:53 
  11. coredns 81819 root    9u    IPv6 0x1509853ac63bfed3      0t0     TCP *:5301 (LISTEN) 
  12. coredns 81819 root   10u    IPv6 0x1509853acd2f5d03      0t0     UDP *:5301 

大功告成,现在你只需要将系统的 DNS IP 设置为 127.0.0.1 就可以了。

(编辑:衡阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读