示例:

[root@corends coredns]# cd /home/coredns/
[root@corends coredns]# ls -al
total
drwxr-xr-x root root Sep : .
drwxr-xr-x. root root Sep : ..
-rwxr-xr-x root root Sep : Corefile
-rwxr-xr-x root root Sep : hosts
-rw-r--r-- root root Sep : install-coredns.sh
[root@corends coredns]# cat install-coredns.sh
#!/bin/bash docker run -d \
--restart always \
--name coredns \
-p :/tcp \
-p :/udp \
-v /home/coredns/hosts:/etc/hosts \
-v /home/coredns/Corefile:/Corefile \
coredns/coredns
[root@corends coredns]# cat Corefile
.: {
hosts {
fallthrough
}
forward . 202.96.128.86 114.114.114.114 8.8.8.8
errors
cache
}
[root@corends coredns]# cat hosts
# 根据实际需要修改
192.168.0.200 devgz.yaohjk.com
192.168.0.200 devboss.yaohjk.com
192.168.0.200 devlogin.yaohjk.com
192.168.0.200 devpay.yaohjk.com
192.168.0.200 devwx.yaohjk.com 192.168.0.200 gz.yaohuiw.net
192.168.0.200 boss.yaohuiw.net
192.168.0.200 login.yaohuiw.net
192.168.0.200 pay.yaohuiw.net
192.168.0.200 wx.yaohuiw.net 192.168.0.199 gz.yaohjk.com
192.168.0.199 boss.yaohjk.com
192.168.0.199 login.yaohjk.com
192.168.0.199 pay.yaohjk.com
192.168.0.199 wx.yaohjk.com 192.168.0.198 boss.yaohuiw.xyz
192.168.0.198 gz.yaohuiw.xyz
192.168.0.198 login.yaohuiw.xyz
192.168.0.198 pay.yaohuiw.xyz
192.168.0.198 wx.yaohuiw.xyz
[root@corends coredns]#

验证:

[root@test2 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.0.246 [root@test2 ~]# nslookup devgz.yaohjk.com
Server: 192.168.0.246
Address: 192.168.0.246# Name: devgz.yaohjk.com
Address: 192.168.0.200
** server can't find devgz.yaohjk.com: NXDOMAIN [root@test2 ~]# nslookup gz.yaohjk.com
Server: 192.168.0.246
Address: 192.168.0.246# Name: gz.yaohjk.com
Address: 192.168.0.199

最新文章

  1. Cocos2d-x 3.X手游开发实例详解
  2. hdu 4941 Magical Forest
  3. PHP 图片文件上传代码分享
  4. C# 判断某程序是否运行
  5. poj2608---几个字母映射到同一个数字
  6. asp.net web api KnownTypeAttribute
  7. [bzoj1070][SCOI2007]修车——费用流
  8. eval & exec(绕过长度限制思路学习)
  9. IntelliJ IDEA 热部署插件 JRebel 安装激活及使用
  10. bootstrap-paginator分页插件的两种使用方式
  11. PHPstorm快捷键Ctrl + Alt + Left 或Right不起作用
  12. python学习笔记(3)
  13. 《精通CSS层叠样式表》
  14. [Maven] guide: maven in 5 minutes
  15. CentOS7下-bash: nano: command not found
  16. VS2012 创建的entityframework 4.1版本
  17. 第八周PSP(11.5--11.9)
  18. Python 列表表达式 ,迭代器(2) Yield
  19. CSS之换行
  20. java基础06 switch

热门文章

  1. LeetCode--Longest Consecutive Sequence(最长连续序列) Python
  2. windows 安装 jenkins笔记
  3. proxy汇总-1
  4. Android---OS
  5. NFA 、DFA 简述
  6. Hibernate Session 4种对象状态
  7. C#将数据导入到Excel表格中
  8. 【Shiro】二、Apache Shiro配置
  9. What size do you use for varchar(MAX) in your parameter declaration?
  10. 94、tensorflow实现语音识别0,1,2,3,4,5,6,7,8,9