首页 > 其他分享 >用Docker搭建DNS服务器

用Docker搭建DNS服务器

时间:2024-04-06 13:22:05浏览次数:79  
标签:Pull DNS no bind dns 服务器 Docker complete

摘要

用bind9的映像搭建DNS

Docker-compose

文件说明如下:
privileged是为了在webmin中更新软件;
映射67的udp端口是为了在webmin中安装DHCP服务。

version: '2'
services:
    bind:
        image: sameersbn/bind:9.16.1-20200524
        container_name: dns
        dns: 127.0.0.1
        environment:
            - ROOT_PASSWORD=you_password
            - TZ=Asia/Shanghai
        ports:
            - 10000:10000
            - 53:53
            - 53:53/udp
            - 67:67/udp
        volumes:
            - ./data/bind:/data
        restart: on-failure
        privileged: true
        logging:
            driver: 'json-file'
            options:
                max-size: '30m'
                max-file: '1'

启动容器

docker-compose up -d

解决53端口被占用

root@ami-home-gateway:/home/david/software/dns# ls
 docker-compose.yml
 root@ami-home-gateway:/home/david/software/dns# docker-compose up -d
 /snap/docker/2285/lib/python3.6/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
   from cryptography.hazmat.backends import default_backend
 Creating network "dns_main" with the default driver
 Pulling web (sameersbn/bind:9.16.1-20200524)...
 9.16.1-20200524: Pulling from sameersbn/bind
 d51af753c3d3: Pull complete
 fc878cd0a91c: Pull complete
 6154df8ff988: Pull complete
 fee5db0ff82f: Pull complete
 7d5f2b88fbe1: Pull complete
 677da372f47f: Pull complete
 4adaef8a17ca: Pull complete
 00abb6dce6f7: Pull complete
 d7852cfdd714: Pull complete
 Digest: sha256:685d9404bf08c177413a7448bfdb7ae71ee002a3fbf917fd8d46d4aadd687522
 Status: Downloaded newer image for sameersbn/bind:9.16.1-20200524
 Creating dns ... 
 Creating dns ... error

ERROR: for dns  Cannot start service web: driver failed programming external connectivity on endpoint dns (7113503da0649c0f745f4a53c16c3c1de24b767f6fbbf816747bf04d987fe803): Error starting userland proxy: listen udp4 0.0.0.0:53: bind: address already in use

ERROR: for web  Cannot start service web: driver failed programming external connectivity on endpoint dns (7113503da0649c0f745f4a53c16c3c1de24b767f6fbbf816747bf04d987fe803): Error starting userland proxy: listen udp4 0.0.0.0:53: bind: address already in use
 ERROR: Encountered errors while bringing up the project.

修改物理服务器

vi /etc/systemd/resolved.conf

文件修改两个地方

#  This file is part of systemd.
 #
 #  systemd is free software; you can redistribute it and/or modify it under the
 #  terms of the GNU Lesser General Public License as published by the Free
 #  Software Foundation; either version 2.1 of the License, or (at your option)
 #  any later version.
 #
 # Entries in this file show the compile time defaults. Local configuration
 # should be created by either modifying this file, or by creating "drop-ins" in
 # the resolved.conf.d/ subdirectory. The latter is generally recommended.
 # Defaults can be restored by simply deleting this file and all drop-ins.
 #
 # Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
 #
 # See resolved.conf(5) for details.

[Resolve]
 # Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
 # Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
 # Google:     8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
 # Quad9:      9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
 # 第一个改动,把这里的IP地址改成服务器在局域网中的地址
DNS=192.168.3.254
 #FallbackDNS=
 #Domains=
 #DNSSEC=no
 #DNSOverTLS=no
#MulticastDNS=no
 #LLMNR=no
 #Cache=no-negative
 #CacheFromLocalhost=no
 # 第二个改动,把#号去掉,yes改成no
DNSStubListener=no
 #DNSStubListenerExtra=
 #ReadEtcHosts=yes
 #ResolveUnicastSingleLabel=no

重新启动resolved服务即可

systemctl restart systemd-resolved

重新启动DNS容器

docker-compose up -d

进入DNS的管理界面

https://ip:10000
用户名:root
密码:在docker-compose.yml中

标签:Pull,DNS,no,bind,dns,服务器,Docker,complete
From: https://www.cnblogs.com/amisoft/p/18117354/use-bind9-as-dns

相关文章

  • Docker 部署war
    要在Docker中部署一个WAR文件到Tomcat服务器,你可以遵循以下步骤。这个过程包括创建一个自定义的Docker镜像,该镜像基于官方的Tomcat镜像,并在此基础上添加你的WAR文件。然后,你可以运行这个自定义镜像来启动一个容器,其中运行着Tomcat服务器和你的Web应用。步骤1:准备你的WAR文件......
  • ARM上面Docker模式安装chrome以及chromedriver的过程
    ARM上面Docker模式安装chrome以及chromedriver的过程背景公司里面有四台鲲鹏服务器想通过ARM的自动化进行功能遍历走查.前期提过需求,但是同时调研之后发现比较困难,作罢了.最近清明假期.想着能够实现以下.最开始的思路虽然网上有一个chromedriver的下载地址:http......
  • [转帖]如何在Ubuntu Linux上使用SNAP安装Docker
    https://zhuanlan.zhihu.com/p/633483748 2人赞同了该文章在UbuntuLinux上安装Docker的最快捷的方法之一是使用SNAP命令。在这里,我们将学习如何使用它。对于那些处理容器化应用程序的人来说,Docker无需介绍。它已经被全球数百家企业和开发人员使用。然而,那些想要......
  • H3C 配置IPv6 DHCP服务器
    H3C交换机配置DHCPv6服务器官方文档:https://www.h3c.com/cn/d_202303/1810058_30005_0.htmIPv6地址计算器:https://www.838dz.com/calculator/5233.html配置调试场景将Router模拟为运营商链路将Switch模拟为DHCPv6服务器实现PC可以从Switch上获取ipv6地址实现上网拓扑......
  • frp内网穿透:基于centos8 云服务器和debian12客户端服务器
    前言入了一台本地工控机盒子,刷成了debian12系统,性能比云服务器要好一点,现在想要远程访问这台盒子,但是盒子又没有公网地址,所以想通过内网穿透的方式,通过云服务器转发请求实现内网穿透。原来体验了一下花生壳,感觉比较麻烦,于是还是想到了使用frp实现。现在记录下具体流程留作后续参......
  • docker、docker-compose 常用命令
    1.docker常用命令创建容器:dockercreate启动容器:dockerstart[id]停止容器:dockerstop [id]停止全部运行的容器:dockerstop`dockerps-q`重启容器:dockerrestart [id] 查看运行中的容器:dockerps查看所有容器(包括已停止的):dockerps-a删除容器:dockerrm容器id查......
  • Docker 安装 Linux 系统可视化监控 Netdata
    docker安装netdata前提准备Docker两种方式部署Netdata1、使用dockerrun命令运行netdata服务2、使用dockercompose运行netdata服务Netdata服务可视化界面Netdata汉化处理前提准备说明:此处使用windows11安装的dockerdesktop&wsl2/apline环境......
  • docker的安装及入门指令
    目录一、将docker安装到云服务器步骤1.更新系统yum版本2.安装所需依赖3.添加docker仓库设置(使用的是阿里云)4.安装docker引擎5.启动docker并开启自动启动6.检查是否安装成功,成功会显示相应版本,否则安装失败二、docker常用命令1.从docker镜像仓库搜索所有与mysql相关......
  • AMD_Ubuntu_Docker部署firefox
    AMD_Ubuntu_Docker部署firefox下载driverhttps://github.com/mozilla/geckodriver/releasesfirefox好像跟chrome不一样高版本的geckodriver可以兼容低版本的firefox所以理论上应该节约了很大的工作量.https://www.mozilla.org/zh-CN/firefox/linux/https://downl......
  • docker运行javaWeb服务,操作文件异常
    一、问题由来部署一个测试服务在自己的服务器上面,然后运行其中的一个功能。然后报错,报错信息如下  二、问题分析自己一开始也很疑惑,怎么会出现这个问题呢,自己明明把对应的文件放在对应的目录下面,并且已经解压。  如果所示,理论上来说不应该啊。可是程序运行......