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账户登录,查 ...
随机推荐
- django_day09_项目相关
django_day09_项目相关 展示数据: 给模板一个querySet对象列表,循环出对象列表obj 普通字段 obj.字段名 ----> 数据库中的数据 外键 obj.外键 ------- ...
- 10_Linux基础-SHELL入门1
@ 目录 10_Linux基础-SHELL入门1 一. 输入输出重定向 二. 2个特殊文件 三. here document 四. tee命令 五. 清空文件内容 六. SHELL入门 SHELL的变 ...
- flink-cdc实时同步mysql数据到elasticsearch
本文首发于我的个人博客网站 等待下一个秋-Flink 什么是CDC? CDC是(Change Data Capture 变更数据获取)的简称.核心思想是,监测并捕获数据库的变动(包括数据 或 数据表的 ...
- 云原生之旅 - 2)Docker 容器化你的应用
前言 上文中我们用Golang写了一个HTTP server,本篇文章我们讲述如何容器化这个应用,为后续部署到kubernetes 做准备. 关键词:Docker, Containerization, ...
- Python微服务实战
文档地址:https://www.qikqiak.com/tdd-book/ GitHub地址:https://github.com/cnych/flask-microservices-users 源 ...
- 授予用户/用户组访问 Kubernetes 的一个名称空间
转载地址:https://www.kuboard.cn/learning/k8s-advanced/sec/rbac/auth-namespace.html 前提条件 已安装 Kuboard v3,版 ...
- 在 Linux 上为特定的用户或用户组启用或禁用 SSH
由于你的公司标准规定,你可能只能允许部分人访问 Linux 系统.或者你可能只能够允许几个用户组中的用户访问 Linux 系统.那么如何实现这样的要求呢?最好的方法是什么呢?如何使用一个简单的方法去实 ...
- day43-反射02
2.Class类 2.1基本介绍 Class类也是类,因此也继承Object类 Class类对象不是new出来的,而是系统创建的 对于某个类的Class类对象,在内存中只有一份,因为类只加载一次 每个 ...
- 独辟蹊径:逆推Krpano切图算法,实现在浏览器切多层级瓦片图
前言 此文我首发于CSDN(所以里面的图片有它的水印) 趁着隔离梳理一下之前做的一个有用的功能:在浏览器中去切割多分辨率瓦片图 这是一个有趣的过程,跟我一起探索吧 阅读本文需具备前置知识:对krpan ...
- jq判断页面滚动条进行样式修改
$(window).scroll(function(){//窗口的滚动条 if($(window).scrollTop()>100){ //垂直滚动条钓offset 大于90时. $(" ...