Docker使用Bind9實(shí)現(xiàn)域名解析的思路詳解
刷新服務(wù)
cd /free_cicdfs0/compose/bind9 docker-compose down; docker-compose up -d
修改配置文件
新版本 配置文件 大致結(jié)構(gòu)發(fā)生了一些改變
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 緩存 查詢 數(shù)據(jù)
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 無(wú)法 ping
broken trust chain resolving 'baidu.com/AAAA/IN': 114.114.114.114#53
解決:
由于是局域網(wǎng)內(nèi)非法DNS,所以將DNS安全關(guān)閉.
[root@192-168-174-42 ~]# vim /etc/named.conf
將下面的兩項(xiàng)設(shè)置為no
dnssec-enable no;
dnssec-validation no;查看 已經(jīng) 區(qū)域 解析,并添加 新的 解析 項(xiàng)
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 安裝 局域網(wǎng) 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 # 測(cè)試 效果 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是監(jiān)控bind的統(tǒng)計(jì)數(shù)據(jù)用的,同時(shí)不需要為了更新某個(gè)zone而重啟bind
查看 默認(rèn)的 解析條目
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";
};添加 自己的 解析條目
多臺(tái) dns 之間 進(jìn)行 協(xié)同 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 書(shū)寫 新的 解析記錄
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
更新 解析記錄
# 局域網(wǎng) x509 證書(shū) 無(wú)法 信任 多重域名
# 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
# 重啟 容器 服務(wù) 即可生效
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到此這篇關(guān)于DOCKER使用BIND9實(shí)現(xiàn)域名解析的文章就介紹到這了,更多相關(guān)DOCKER使用BIND9實(shí)現(xiàn)域名解析內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Docker搭建自己的本地鏡像倉(cāng)庫(kù)的步驟
今天小編就為大家分享一篇關(guān)于Docker搭建自己的本地鏡像倉(cāng)庫(kù)的步驟,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-03-03
Docker 倉(cāng)庫(kù)管理和Docker Dockerfile詳解
倉(cāng)庫(kù)(Repository)是集中存放鏡像的地方,以下介紹一下 Docker Hub,當(dāng)然不止 docker hub,只是遠(yuǎn)程的服務(wù)商不一樣,操作都是一樣的,對(duì)Docker 倉(cāng)庫(kù)管理相關(guān)知識(shí)感興趣的朋友一起看看吧2023-11-11
docker?gitea?drone實(shí)現(xiàn)超輕量級(jí)CI?CD實(shí)戰(zhàn)詳解
這篇文章主要為大家介紹了docker?gitea?drone實(shí)現(xiàn)超輕量級(jí)CI?CD實(shí)戰(zhàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10
docker使用storage出現(xiàn)Exit導(dǎo)致文件無(wú)法上傳服務(wù)器的問(wèn)題及解決方案
這篇文章主要介紹了docker使用storage出現(xiàn)Exit導(dǎo)致文件無(wú)法上傳服務(wù)器解決方案,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06
docker-compose鏡像發(fā)布springboot項(xiàng)目的流程分析
Docker-Compose項(xiàng)目由Python編寫,調(diào)用Docker服務(wù)提供的API來(lái)對(duì)容器進(jìn)行管理。因此,只要所操作的平臺(tái)支持Docker API,就可以在其上利用Compose來(lái)進(jìn)行編排管理,接下來(lái)通過(guò)本文給大家介紹docker-compose發(fā)布springboot項(xiàng)目的流程分析,一起看看吧2021-06-06
3分鐘用Docker搭建一個(gè)Minecraft服務(wù)器
這篇文章主要介紹了3分鐘用Docker搭建一個(gè)Minecraft服務(wù)器的相關(guān)資料,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下2016-11-11
mysql8.4.0實(shí)現(xiàn)主從復(fù)制部署
主從復(fù)制是 MySQL 中一種用于實(shí)現(xiàn)數(shù)據(jù)冗余、提高可用性和性能的重要機(jī)制,本文主要介紹了mysql8.4.0實(shí)現(xiàn)主從復(fù)制部署,具有一定的參考價(jià)值,感興趣的可以了解一下2024-07-07
mac通過(guò)docker一鍵部署Nexus3的過(guò)程記錄
編寫一些簡(jiǎn)易的 shell 腳本幫我們快速的搭建服務(wù)器,猿們只要按著套路“一步一步”的操作,基本上都可以快速部署服務(wù),這篇文章主要介紹了mac通過(guò)docker一鍵部署Nexus3及安裝步驟,需要的朋友可以參考下2022-10-10

