coredns使用etcd
CoreDNS使用ETCD存储主机记录。etcd安装略过。
Corefile内容
.:53 {# 绑定本机IPbind 192.168.1.2# etcd地址etcd {path /corednsendpoint http://192.168.1.2:2379fallthrough}# 最后所有的都转发到系统配置的上游dns服务器去解析forward . /home/apps/coredns/conf/forwards# 缓存时间ttlcache 1800# 自动加载配置文件的间隔时间reload 6s# 输出日志log# 输出错误errors }
forwards内容
nameserver 223.6.6.6 nameserver 223.5.5.5
etcd相关操作
- 添加主机记录
etcdctl put /coredns/com/example/x1 '{"host":"192.168.1.3","ttl":60}'
- 查看所有主机记录
etcdctl get --prefix /coredns
- 删除指定主机记录
etcdctl del /coredns/com/example/x1
nslookup测试
nslookup example.com 192.168.1.2