Configuring DNS servers with Docker

Source: Internet
Author: User

1. Overview

The Sameersbn/bind image in Dockerhub provides the ability to build a DNS server, and this article gives an example of using this image to build a DNS server.

2. Environment

DNS server host ip:10.11.150.73 domain name: master.open.com

ip:10.11.150.74 Domain name for client 1: node.open.com

ip:10.11.150.75 Domain name for client 2: node2.open.com

Test environment in 73, 74, 75 machine can not connect Dockerhub, in the connection can connect 73, 74, 75 machine and Dockerhub.

3. Build 3.1 Import Sameersbn/bind image

To download the Sameersbn/bind image in a transit machine:

Docker Pull Sameersbn/bind:latest

To save the image as a tar package:

Docker Save-o Sameersbn_bind. Tar sameersbn:bind

The tar package is copied to the/opt/scs/openxxs/directory of the 73 machine via SCP (any directory with read and write permission):

SCP sameersbn_bind. Tar [Email protected] 10.11. 150.73:/opt/scs/openxxs/

Import the image on the 73 machine:

Docker load--input sameersbn_bind. Tar

At this time, on the 73 machine, there is a sameersbn/bind mirror:

3.2 New and started the DNS server container

Run the following command on the 73 machine to create and start the container:

Docker run--name='bind':/udp-ewebmin_enabled=false-v/opt/scs/ Openxxs/bind:/data Sameersbn/bind:latest

Where--name is named Bind;-p Open 53:53/UDP port for other hosts to access the DNS server; the Sameersbn/bind mirror itself installs a Webmin service that provides a browser interface for user-configurable domain name entries. This article uses the configuration file to modify the DNS settings so that the WEBMIN service is disabled via-e Webmin_enabled=false, and-V mounts the/opt/scs/openxxs/bind directory of the 73 host (which can also be a different directory). After the new container is created, the Bind/ect and Bind/lib directories are generated under this directory, where the ETC directory is the relevant configuration file for DNS.

3.3 Parameter Configuration

Modify the/etc/resolv.conf file for 73, 74, 75 hosts, and add the following to represent one of the DNS servers using the 73 machine:

10.11. 150.73

In the/opt/scs/openxxs/bind/bind/etc directory, open the named.conf file with the following contents:

It can be seen that the relevant configuration information of DNS is divided into three files, named.conf.options, named.conf.local and Named.conf.default-zones. Open the Named.conf.options file, modify the Allow-query and Allow-transfer fields as follows to allow 73, 74, 75 machines to use the DNS service on the 73 machine.

Open the Named.conf.local file to add forward parsing and reverse parsing (note that you need to add a semicolon after each zone):

Based on db.local new forward parsing file Forward.open (consistent with naming in named.conf.local):

CP Db.local Forward.open

The contents are as follows:

New reverse parsing file Reverse.open based on db.127 (consistent with naming in named.conf.local):

CP DB. 127 Reverse.open

The contents are as follows:

After modifying the configuration file, you need to reload the configuration file into the Bind container:

Docker exec-i-t bind bash

After entering the Bind container, the/etc/bind directory in the box corresponds to the/OPT/SCS/OPENXXS/BIND/BIND/ETC directory in the 73 host. Perform the following command to check the syntax of the configuration file:

Named-checkconf

After the syntax is fine, use the RNDC command to reload the configuration information:

RNDC Reconfig

If you just modified some of the entries for an area, you can update the region by updating the open.com area with the following command:

RNDC Reload Open.com
3.4 Testing

Test on the 73 machine as follows, success:

Test on the 74 machine as follows, success:

Configuring DNS servers with Docker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.