以下是在使用 Windows 时提供的快速入门开发指南。
-
请确保已经 设置好 GOPATH
-
克隆 coredns 及其所有依赖项:
go get github.com/coredns/coredns
-
导航到源:
cd $ENV:GOPATH\src\github.com\coredns\coredns
-
分支(而不克隆)coredns
-
将源更新为指向你的存储库:
git remote set-url origin https://github.com/USERNAME/coredns.git
-
打开你的编辑器:
code .
-
创建一个名为
Corefile
的新文件并填充该文件# Only port 53 is supported as NSLOOKUP no longer supports non-standard ports .:53 { # Your router proxy . 192.168.1.1:53 file D:\dev\zone\example.org example.org errors log }
-
创建
example.org
文件example.org. IN SOA dns.example.org. domains.example.org. ( 2012062701 ; serial 300 ; refresh 1800 ; retry 14400 ; expire 300 ) ; minimum @ IN NS dns.example.com. @ 42000 IN A 127.0.0.1 @ 42000 IN A 127.0.0.2 @ 42000 IN A 127.0.0.3 api 42000 IN CNAME sample.service.dns.example.de. www 42000 IN CNAME sample.service.dns.example.de. blog 42000 IN CNAME sample.service.dns.example.de. @ 3600 IN MX 1 ASPMX1.L.google.com. @ 3600 IN MX 1 ASPMX2.L.google.com. @ 3600 IN MX 1 ASPMX3.L.google.com. @ 300 IN TXT "v=spf1 include:_spf.google.com ~all"
-
你应该能够通过 VSCode 来执行 coredns,使用以下命令进行测试
> nslookup - localhost Default Server: UnKnown Address: ::1 > example.org Server: UnKnown Address: ::1 Name: example.org Addresses: 127.0.0.1 127.0.0.2 127.0.0.3
-
使用
github.com\coredns\coredns
就像使用你自己的存储库一样。这样做是为了确保 VSCode 中的调试工作正常。 -
你可能希望将以下内容添加到你的全局
.gitignore
```
coredns.exe
Corefile
.vscode
debug
```