docker使用bind9实现域名解析
刷新服务
cd /free_cicdfs0/compose/bind9
docker-compose down; docker-compose up -d
修改配置文件
新版本 配置文件 大致结构发生了一些改变
cat /free_cicdfs0/data/bind9/etc/bind/named.conf
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
从 114 缓存 查询 数据
cat > /free_cicdfs0/data/bind9/etc/bind/named.conf.options <<"EOF"
# include "/etc/rndc.key";
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndckey"; };
};
options {
// set no
dnssec-enable no;
dnssec-validation no;
listen-on port 53 { any; };
allow-query { any; };
forwarders {
114.114.114.114;
};
};
EOF
chmod 777 -R /free_cicdfs0/data/bind9/
chown root:root -R /free_cicdfs0/data/bind9/
chown root:named -R /free_cicdfs0/data/bind9/
docker-compose up -d
# log error
couldn't add command channel 127.0.0.1#953: file not found
docker cp -a bind9:/etc/bind /free_cicdfs0/data/bind9/etc/
docker cp -a bind9:/var/lib/bind /free_cicdfs0/data/bind9/var/lib/
可以 dig 无法 ping
broken trust chain resolving 'baidu.com/AAAA/IN': 114.114.114.114#53
解决:
由于是局域网内非法DNS,所以将DNS安全关闭.
[root@192-168-174-42 ~]# vim /etc/named.conf
将下面的两项设置为no
dnssec-enable no;
dnssec-validation no;
查看 已经 区域 解析,并添加 新的 解析 项
cat /free_cicdfs0/data/bind9/etc/bind/named.conf.default-zones
// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/usr/share/dns/root.hints";
};
// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
https://nginx164190.zk.wh.com/
192.168.164.190 nginx164190.zk.wh.com
在 linux 安装 局域网 cert
# 添加 解析 条目
vi /etc/hosts
192.168.164.190 nginx164190.zk.wh.com
[root@node01 ~]# curl https://nginx164190.zk.wh.com/
curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
curl -o install_cert_linux.zip http://192.168.164.190:40080/install_cert_linux.zip
unzip install_cert_linux.zip
cd install_cert_linux
./install_cert.sh
# 测试 效果
curl https://nginx164190.zk.wh.com/
<html>
<head><title>Index of /</title></head>
<body>
<h1>Index of /</h1><hr><pre><a href="../">../</a>
<a href="_wildcard.zk.wh.com.crt">_wildcard.zk.wh.com.crt</a> 18-Aug-2021 08:53 1464
<a href="_wildcard.zk.wh.com.pem">_wildcard.zk.wh.com.pem</a> 18-Aug-2021 08:53 1464
<a href="install_cert_linux.zip">install_cert_linux.zip</a> 19-Aug-2021 07:30 2M
<a href="rootCA-key.pem">rootCA-key.pem</a> 18-Aug-2021 08:53 2488
<a href="rootCA.pem">rootCA.pem</a> 18-Aug-2021 08:53 1635
<a href="test">test</a> 18-Aug-2021 08:47 7
</pre><hr></body>
</html>
rndc
1、953端口是rndc 的端口
2、rndc是监控bind的统计数据用的,同时不需要为了更新某个zone而重启bind
查看 默认的 解析条目
cat /etc/bind/named.conf.default-zones
// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/usr/share/dns/root.hints";
};
// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
添加 自己的 解析条目
多台 dns 之间 进行 协同
SOA
NS
# A 代表 解析到 ipv4
@ IN A 127.0.0.1
# A 代表 解析到 ipv6
@ IN AAAA ::1
# ptr 代表 逆向解析
1.0.0 IN PTR localhost.
cat /etc/bind/named.conf
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
// add you zones
include "/etc/bind/named.conf.my-zones";
# 模仿 /etc/bind/named.conf.default-zones 书写 新的 解析记录
cat > /etc/bind/named.conf.my-zones <<"EOF"
zone "zk.wh.com" {
type master;
file "/etc/bind/db.zk.wh.com";
};
zone "192.in-addr.arpa" {
type master;
file "/etc/bind/db.192";
};
EOF
# 模仿db 文件
cat /etc/bind/db.local
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA localhost. root.localhost. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
@ IN A 127.0.0.1
@ IN AAAA ::1
cat > /etc/bind/db.zk.wh.com <<"EOF"
$TTL 86400
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
;
@ IN NS localhost.
nginx164190 IN A 192.168.164.190
zcloud164190 IN A 192.168.164.190
EOF
# 模仿 逆解 文件
cat /etc/bind/db.127
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
1.0.0 IN PTR localhost.
cat > /etc/bind/db.192 <<"EOF"
$TTL 86400
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
;
@ IN NS localhost.
190.164.168 IN PTR nginx164190.
EOF
更新 解析记录
# 局域网 x509 证书 无法 信任 多重域名
# Reminder: X.509 wildcards only go one level deep, so this won't match a.b.zk.wh.com ️
cat > /free_cicdfs0/data/bind9/etc/bind/db.zk.wh.com <<"EOF"
$TTL 86400
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
;
@ IN NS localhost.
nginx164190 IN A 192.168.164.190
zcloud164190 IN A 192.168.164.190
hub-docker IN A 192.168.99.100
EOF
# 重启 容器 服务 即可生效
ssh root@192.168.99.2
cd /free_cicdfs0/composes/bind9
docker-compose restart
# test
ping hub-docker.zk.wh.com
PING hub-docker.zk.wh.com (192.168.99.100) 56(84) bytes of data.
64 bytes from 192.168.99.100: icmp_seq=1 ttl=64 time=0.172 ms
64 bytes from 192.168.99.100: icmp_seq=2 ttl=64 time=0.152 ms
有兴趣的同学欢迎进群交流
docker使用bind9实现域名解析的更多相关文章
- docker搭建及使用:centos7.0+docker+flask+nginx
flask笔记: centos7安装Docker: yum install docker 启动docker服务: service docker start 构建基本镜像: sudo docker pu ...
- ubuntu安装docker{ubuntu16.04下安装docker}
一.开始安装 第一步: 由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本: $ sudo apt-get remove docker docker-engine d ...
- 解决docker镜像pull超时问题
第一步:通过dig @114.114.114.114 registry-1.docker.io找到可用IP dig @114.114.114.114 registry-1.docker.io 第二步: ...
- docker 出现 Error response from daemon
第一步:通过dig @114.114.114.114 registry-1.docker.io找到可用IP navy@deepin:~/Desktop$ dig @.docker.io ; <& ...
- Caffe学习系列(三)Docker安装及一些问题的记录
前言: Docker安装倒是很简单,按照步骤轻松完成,但是在联网方面还是出现问题,大概是伟大的祖国防火墙将其拦下,但在开发中要遇山开山,见水搭桥.在其中我将解决方法记录下来,每次解决了困难想分享找不到 ...
- Docker 配置国内镜像
前言 当我们使用Docker pull 拉取镜像时,有时候因网络问题,导致获取镜像报错,如下 :Error response from daemon:Get https://registry-1.co ...
- Ubunut18 安装docker环境&&AWD攻防平台部署
docker:有两个版本:docker-ce(社区版)和docker-ee(企业版). 参考官网地址:https://docs.docker.com/engine/installation/linux ...
- Docker获取镜像报错docker: Error response from daemon
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled ...
- 解决报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshaketimeout
报错: [root@localhost /]# sudo docker pull ubuntuError response from daemon: Get https://registry-1.do ...
- CentOS8上用Docker部署开源项目Tcloud
一.安装Docker 1.我是虚拟机装的Centos7,linux 3.10 内核,docker官方说至少3.8以上,建议3.10以上(ubuntu下要linux内核3.8以上) root账户登录,查 ...
随机推荐
- 荣获 Neo4j Certified Professional
在学习 Neo4j 的过程中,偶然得知官方的认证考试,所以当时就决定通过这项考试,功夫不负有心人,我成功的拿到了Neo4j Certified Professional认证证书 关于认证途径,请访问链 ...
- Toast 部分记录丢失问题处理
在日常数据库运维过程中,我们可能会遇到类似以下的错误.该错误信息是由于部分tuple的 toast 字段丢失,导致数据无法访问.需要通过游标方式,将可以访问的数据备份出来. test=# create ...
- 【读书笔记】C#高级编程 第二十四章 文件和注册表操作
(一)文件和注册表 对于文件系统操作,相关的类几乎都在System.IO名称空间中,而注册表操作由System.Win32名称空间中的类来处理. (二)管理文件系统 System.MarshalByR ...
- Vben Admin 源码学习:状态管理-角色权限
前言 本文将对 Vue-Vben-Admin 角色权限的状态管理进行源码解读,耐心读完,相信您一定会有所收获! 更多系列文章详见专栏 Vben Admin 项目分析&实践 . 本文涉及到角 ...
- axos在async模式下如何中断请求
main.js import axios from 'axios' Vue.prototype.$http = axios Test.vue <template> <div clas ...
- Twikoo私有化部署教程--迁移腾讯云
目录 备份数据 私有化部署 创建容器 导入数据 重新配置twikoo面板设置 引入前端CDN Nginx https反代http 作者:小牛呼噜噜 | https://xiaoniuhululu.co ...
- Redis核心设计原理(深入底层C源码)
Redis 基本特性 1. 非关系型的键值对数据库,可以根据键以O(1) 的时间复杂度取出或插入关联值 2. Redis 的数据是存在内存中的 3. 键值对中键的类型可以是字符串,整型,浮点型等,且键 ...
- 支付宝沙箱服务 (结合springboot实现,这里对接的是easy版本,工具用的是IDEA,WebStrom)
一:打开支付宝开发平台,登录,然后点击控制台 https://open.alipay.com/ 二:滚动到底部,选着沙箱服务 三:获取到对接要用的appId和公钥私钥 四:打开IDEA导入所需的xml ...
- [s905l3]性价比神机mgv3000全网首拆,刷armbian实现更多价值!
最近花55淘了一台mgv3000,s905l3,2+16G带蓝牙,真的性价比没得说 S905L3 工艺28nm差于s905l3a 主频1.9Ghz,超频可以达到2Ghz,GPU是Mail450,当服务 ...
- P8548 小挖的买花 方法记录
原题链接 小挖的买花 题目背景 小挖喜欢买花,但是 ta 太懒了!所以这个任务全权交给了你. 题目描述 花店里只有 \(n\) 株花,每一株花都有三个属性:价格 \(cost_i\).美丽度 \(be ...