CoreDNS Windows
CoreDNS for Windows 注册服务 开机自启
- 首先写Corefile配置文件
- 注册服务且开机自启
- 安装WinSW
- 编写xml配置文件
- 注册、启动
- 测试
- 修改网卡的DNS
此篇博文针对Windows下的CoreDNS配置
首先写Corefile配置文件
.:53 {# 绑定interface ipbind 127.0.0.1# 先走本机的hostshosts C:\Windows\System32\drivers\etc\hosts {fallthrough}# 转发上游dns服务器forward . tls://223.5.5.5:853 {tls_servername dns.alidns.comforce_tcpmax_fails 3}# 缓存时间ttlcache 120reload 10slogerrors
}
注册服务且开机自启
准备注册服务,但是,我尝试了以下方式都启动失败了
New-Service -Name "CoreDNS" -BinaryPathName '"D:\Applications\apps\coredns\1.8.3\coredns.exe -conf D:\Applications\apps\coredns\Corefile"' -Description "CoreDNS Service" -StartupType "Automatic"
New-Service -Name "CoreDNS" -BinaryPathName '"powershell -file D:\Applications\apps\coredns\CorednsService.ps1 -WindowStyle Hidden"' -Description "CoreDNS Service" -StartupType "Automatic"
New-Service -Name "CoreDNS" -BinaryPathName '"Start-Job -ScriptBlock { D:\Applications\apps\coredns\current\coredns.exe -conf D:\Applications\apps\coredns\Corefile }"' -Description "CoreDNS Service" -StartupType "Automatic"
sc create CoreDNS binpath= "D:\Applications\apps\coredns\current\coredns.exe -conf D:\Applications\apps\coredns\Corefile" start= auto displayname= "CoreDNS Service"
由于Windows的缘故,一个程序想要注册为服务并正常运行,程序自身必须实现Windows Services API,如果想把任何可执行程序都正常注册为服务,需要借助第三方的工具,例如WinSW
尝试使用https://github.com/winsw/winsw这个工具注册CoreDNS服务发现没有问题
安装WinSW
首先安装WinSW,推荐使用Scoop管理工具,直接GitHub下载也可行
scoop install winsw
复制一份Winsw.exe
到CoreDNS目录下,最好重命名为CoreDNS-Service.exe
,和后面的xml配置文件一致
编写xml配置文件
在CoreDNS目录下编写CoreDNS-Service.xml
<service><id>CoreDNS</id><name>CoreDNS</name><description>CoreDNS Service (Powered By WinSW)</description><executable>D:\Applications\apps\coredns\current\coredns.exe</executable><arguments>-conf D:\Applications\apps\coredns\Corefile</arguments><onfailure action="restart" delay="8 sec"/><startmode>Automatic</startmode><log mode="reset"/>
</service>
executable和arguments配置自行修改,因为我用Scoop安装软件,Current目录是软链接指向最新版CoreDNS目录,故把CoreDNS-Service.exe和CoreDNS-Service.xml放在外面,不受软件升级影响
D:\Applications\apps\coredns
├── 1.8.3
│ ├── coredns.exe
│ ├── install.json
│ └── manifest.json
├── CoreDNS-Service.err.log
├── CoreDNS-Service.exe
├── CoreDNS-Service.out.log
├── CoreDNS-Service.wrapper.log
├── CoreDNS-Service.xml
├── CorednsService.ps1
├── Corefile
└── current -> D:\Applications\apps\coredns\1.8.3
注册、启动
最后注册服务,并启动,路径自行修改
D:\Applications\apps\coredns\CoreDNS-Service.exe install
D:\Applications\apps\coredns\CoreDNS-Service.exe start
测试
使用nslookup测试一下,成功!
修改网卡的DNS
最后记得把网卡的DNS服务器第一项修改为127.0.0.1(配置文件中绑定的那个ip
CoreDNS Windows相关推荐
- DoT/DoH/DoQ 之 CoreDNS配置
Dot/DoH/DoQ 的好处就不用多说了,那么如何让你的网络用上DoT/DoH/DoQ呢? DoT:DNS over TLS DoH:DNS over HTTPS DoQ:DNS over QUIC ...
- k8s kubernetes 核心组件 CoreDNS 域名解析服务 学习总结
k8s kubernetes 核心组件 CoreDNS 域名解析服务 学习总结 大纲 基础概念 CoreDNS下载与安装 DNS资源记录配置说明 CoreDNS配置文件Corefile语法总结 Cor ...
- Windows部署K8S
Windows部署K8S 参考链接 官网部署文档 在 Windows 上安装和设置 kubectl 在你开始之前 在 Windows 上安装 kubectl 在 Windows 上使用 curl 安装 ...
- CoreDNS篇4-编译安装unbound
本文主要介绍coredns的unbound插件进行编译安装的过程及常用的配置方法. coredns官方的unbound文档unbound (coredns.io),以及unbound插件的github ...
- GCC 在 Linux、Windows 系统安装
1. GCC 简介 谈到 GCC,就不得不提 GNU 计划.GNU 全称 GNU's Not UNIX,又被称为"革奴计划",由理查德·斯托曼于 1983 年发起.GNU 计划的最 ...
- Windows 64位下安装Redis详细教程
Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. 工具/原料 Windows 64位操作系统 Redis 安装包 方法/步骤 Redis 安装包下载 下载地址:h ...
- Go语言环境搭建(Windows+Linux)
目录 1. Windows安装配置 2. Linux安装配置 1. Windows安装配置 1️⃣ 下载SDK SDK 的全称是Software Development Kit(软件开发工具包) ,包 ...
- Nginx最新版安装教程(Windows+Linux)
目录 一.Nginx安装-Windows 1. 下载解压 2. 启动 3. 测试是否启动成功 4. 配置监听端口 二.Nginx安装-Linux 1. 下载解压 2. 上传到服务器 3. 配置 第一步 ...
- Linux 2 的 Windows 子系统上发布 CUDA
Linux 2 的 Windows 子系统上发布 CUDA 为响应大众需求,微软 宣布 在 2020 年 5 月的 建造 大会上推出了 建造 ( WSL 2 ) – GPU 加速功能.这一特性为许多计 ...
最新文章
- C#中如何得到机器的IP地址
- 大数据如何在商业银行战略规划中发挥作用
- LDD3源码分析之阻塞型I/O
- formal method online checking tool
- Java常见异常(Runtime Exception )小结
- Python的3种字符串格式化,做个超全对比!
- tab菜单的点击的动态效果和内容页面的关联显示jQuery
- 【TensorFlow】稀疏矢量
- 2021 年百度之星·程序设计大赛 - 初赛二 1002 随机题意(区间贪心)
- 计算机网络入门知识大全,计算机网络基础知识汇总(超全).doc
- 锋利的jquery学习
- SQLite读写同步之WAL机制
- 海尔希望小学:同一片蓝天下梦想启航
- 洛谷 P4147 玉蟾宫
- 从词向量到概念发现,知识图谱让机器更加理解人类语言
- Java系统环境变量配置
- 验证哥德巴赫猜想:任何一个大于等于6的偶数均可表示为两个素数的和。如6=3+3,8=3+5,,18=5+13。试编写程序,要求将输入的一个偶数表示成两个素数之和。 输入输出样例如下:
- Cisco Packet Tracer 配置交换机与路由器静态路由
- twitter和新浪微博--比较
- 织梦php实现评论,织梦文章评论功能的使用