Docker sets up DNS server in 1 minute

Here we use the docker version docker-dnsmasq corresponding to dnsmasq. ...
Guide to Use

Here we use the docker version docker-dnsmasq corresponding to dnsmasq.

Guide to Use

Download Mirror

docker pull docker-dnsmasq

Create the simplest configuration /opt/dnsmasq.conf

#dnsmasq config, for a complete example, see: # http://oss.segetech.com/intra/srv/dnsmasq.conf #dns parsing log log-queries #Define Host to IP Mapping address=/h0/172.17.205.28 address=/h1/172.17.205.32 ...

Run Container

docker run \ --name dnsmasq \ -d \ -p 53:53/udp \ -p 8080:8080 \ -v /opt/dnsmasq.conf:/etc/dnsmasq.conf \ --log-opt "max-size=100m" \ -e "HTTP_USER=admin" \ -e "HTTP_PASS=admin" \ --restart always \ jpillora/dnsmasq

Parameter Description

Name Explain max-size Maximum Log Save HTTP_USER Username HTTP_PASS Logon Password

Visit Pull http://localhost:8080

  • Log in with admin/admin account password.
dnsmasq interface

DNS configuration

  • In/etc/Resolv.confAdd the following two sentences before the file
  • Adding only 172.17.205.28 DNS will fail resolution
nameserver 127.0.0.1 #Required nameserver 172.17.205.28 #Mandatory [local primary network card] ...

test

  • This machine is configured like any other machine
  • Required before it will take effect because DNS resolution will resolve from top to bottom
root@center ~# ping h1 PING h1 (172.17.205.32) 56(84) bytes of data. 64 bytes from 172.17.205.32 (172.17.205.32): icmp_seq=1 ttl=64 time=0.155 ms 64 bytes from 172.17.205.32 (172.17.205.32): icmp_seq=2 ttl=64 time=0.203 ms ^C --- h1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.155/0.179/0.203/0.024 ms

Increase Resolution

  • Click Save to take effect automatically in a few seconds
address=/h0/172.17.205.28 address=/h1/172.17.205.32 address=/h2/172.17.205.33 address=/h3/172.17.205.34 address=/h4/172.17.205.35 ....

Be careful

  • It is recommended to keep the hostname of other machines as configured above
  • Otherwise, the following problems may occur
root@asdf ~# ping h0 ping: h0: Name or service not known

13 June 2020, 12:52 | Views: 2732

Add new comment

For adding a comment, please log in
or create account

0 comments