在我開發的項目notr內網穿透當中引入DNS來解決一個問題:git
每次客戶端鏈接都會修改其A記錄,解析到鏈接的服務器節點上。目前DNS版本還很是簡單,已經開源成notrns項目。可是這個項目還有幾個問題:github
經過github瞭解到CoreDNS和etcd兩個項目,就想着用CoreDNS代替notrns來作動態域名解析,使用etcd來作存儲,使用etcd是基於如下考量:mongodb
CoreFile:數據庫
notr.tech {
etcd {
path /skydns
endpoint http://localhost:2379
upstream
}
log
}
複製代碼
➜ bin git:(master) ./etcdctl put /skydns/tech/notr/yingjiu/ '{"host":"192.168.1.2"}'
OK
➜ bin git:(master) nslookup yingjiu.notr.tech 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: yingjiu.notr.tech
Address: 192.168.1.2
➜ bin git:(master) ./etcdctl put /skydns/tech/notr/yingjiu/ '{"host":"192.168.1.3"}'
OK
➜ bin git:(master) nslookup yingjiu.notr.tech 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: yingjiu.notr.tech
Address: 192.168.1.3
➜ bin git:(master)
複製代碼
接下來只須要在registry將etcd client集成進去便可,改造完以後整個軟件變成了下圖所示的流程。bash