惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Help Net Security
Help Net Security
G
Google Developers Blog
雷峰网
雷峰网
WordPress大学
WordPress大学
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Engineering at Meta
Engineering at Meta
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
AWS News Blog
AWS News Blog
F
Full Disclosure
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
J
Java Code Geeks
U
Unit 42
C
Cyber Attacks, Cyber Crime and Cyber Security
V
V2EX
C
Cisco Blogs
博客园 - 司徒正美
Project Zero
Project Zero
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
Scott Helme
Scott Helme
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
S
Securelist
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
S
Schneier on Security
G
GRAHAM CLULEY
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyberwarzone
Cyberwarzone
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
T
Threatpost
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
The Register - Security
The Register - Security
S
Security Archives - TechRepublic
博客园 - Franky
N
News | PayPal Newsroom
Simon Willison's Weblog
Simon Willison's Weblog
S
SegmentFault 最新的问题
W
WeLiveSecurity
A
Arctic Wolf
B
Blog

云野开源志

OpenClaw npm 升级踩坑记:从版本冲突到模块丢失 免责声明 openclaw(moltbot、Clawdbot)常见异常 大模型配置-千问免费版 初始化OpenClaw 安装openclaw记录 大年初一桃花谷 CheckSSL.sh - SSL证书到期时间监控脚本 g.sh - Go语言环境管理工具安装脚本 install-cri-docker.sh - cri-dockerd安装脚本 install-docker.sh - Docker Engine快速安装脚本 install-docker2.sh - Docker 交互式安装脚本 install-nginx.sh - Nginx官方源快速安装脚本 install-zerotier.sh - ZeroTier 虚拟网络快速安装脚本 mng.sh - Nginx配置文件合并脚本 OpenSSL.sh - 自签名 SSL 证书生成脚本 SystemInfoMonitor.sh - 系统资源监控告警脚本 UpdateImages.sh - Docker 镜像批量更新脚本 为Hugo Next主题添加Umami统计支持 解忧杂货铺 - 栏目声明 Certd - 解决多平台SSL证书管理难题的神器 轻量级网络端口监控工具 GeoLite2 自动搬运仓库使用手册 MaxMind 免费账号注册 CloudFlare Accel hugo-theme-stack集成Umami openresty编译添加geoip2模块支持 GPU加速云原生应用,开启高性能计算新纪元 5. K8S Service与Ingress 4. K8S 控制器 Rancher搭建 3. K8S Pod 资源管理 2. K8S 基础资源管理 1. K8S 简介和认证介绍 Rancher集成AzureAD认证 Harbor 部署搭建 站点留言板 关于 友情链接
Docker 搭建私有 DNS 服务器
云野开源志 · 2025-01-14 · via 云野开源志

总结摘要

本文详细介绍了如何使用 Docker 快速部署基于 BIND9 的私有 DNS 服务器(sameersbn/bind 镜像),涵盖容器运行参数(特别是 --net=host 的必要性)、Web 管理界面配置、主区域与 A 记录创建,并重点解决了 Linux 客户端主机名解析失败的问题,提供了临时和永久设置搜索域(search domain)的方法,适用于内网域名解析、开发测试环境等场景。

daocker搭建私有dns服务器

前置量:需要docker环境,版本无要求

1
2
3
4
## 创建持久化存放文件的目录
mkdir -p /container-data/bind
## 使用容器创建应用
docker run --net=host --name bind -d --restart=always --publish 53:53/tcp --publish 53:53/udp --publish 10000:10000/tcp --volume /container-data/bind:/data sameersbn/bind:9.16.1-20200524

注意:私有dns部署的话用以下命令可以使用,但是该dns服务器只能解析记录的域名,没有记录的域名无法解析。原因是,容器内的网络默认是桥接的docker0的网卡,在容器内是无法访问公网的,所以就算配置了转发,也无法进行解析。

1
docker run --name bind -d --restart=always --publish 53:53/tcp --publish 53:53/udp --publish 10000:10000/tcp --volume /container-data/bind:/data sameersbn/bind:9.16.1-20200524

如果需要解析应记录以外的域名地址,则需要添加 --net=host 参数,这个参数将容器加入到主机的网络命名空间,直接使用主机的网络资源,可以提高网络性能,但是容器与主机之间的隔离性较差。

如果未关闭防火墙则使用systemctl stop firewalld ;systemctl disable firewalld关闭防火墙,如果docker run创建容器时未添加--net=host参数,则需要在防火墙上打开对应端口

1
2
3
firewall-cmd --add-port={53,10000}/tcp --permanent
firewall-cmd --add-port=53/udp --premanent
firewall-cmd --reload

处理好防火墙之后,使用浏览器,打开https://IP:10000地址,默认用户名和密码 root/password.

登录之后在左侧导航栏选择:server => BIND DNS Server => 创建新的主区域

image-20230223220627856

输入域名,可以是一级域名test或test.com。

image-20230223220831087

点击新建完成创建域名。

创建好之后,点击左上角的【地址】进行创建映射

image-20230223221050908

输入主机名以及对应的IP,点击新建

image-20230223221147229

新建完成之后,可以看到下方已经列出刚刚创建的映射,点击右上角应用配置,就创建好了

image-20230223221250108

使用cmd或这linux中的nslookup命令进行验证。

image-20230223221414200

解析成功,证明dns服务器解析记录生效。

在Linux中主机名解析

在Linux中,我们将服务器的dns地址改为刚刚创建的dns服务器的地址。使用ping命令或nslookup命令可以看到域名解析成功。

但是同样使用ping或者nslookup解析主机名就无法解析到ip地址。如图

image-20230223221710517

解决办法:

可以设置文件/etc/resolv.conf,在文件中加入默认搜索域search test.chang,多个搜索域可以使用空格隔开。如图:

image-20230223222333129

但是这样设置是临时的,重启服务器或者重启网络之后会被更改,永久修改办法:

1、修改/etc/sysconfig/network-scripts/ifcfg-***

image-20230223222526616

2、修改NetworkManager.conf

image-20230223222625791

3、修改dns服务器的named.conf文件

image-20230223222748547

修改之后如下,成功

image-20230223222836757