Beruflich Dokumente
Kultur Dokumente
This is the 壬�rst part of a series of how-to’s where I describe setting up and using various docker
containers for home and production use.
Introduction
The Domain Name System (http://en.wikipedia.org/wiki/Domain_Name_System) (DNS) server takes a
fully quali壬�ed domain name (FQDN) such as www.example.com and returns the corresponding IP
address such as 93.184.216.34 .
By setting up a local DNS server you don’t rely on your ISP’s DNS servers which are often bogged
down by incoming tra艀c which makes responses to DNS queries take longer to get serviced.
Besides performing domain name resolutions, a BIND server also acts as a DNS cache. This means
that DNS queries could get serviced from the local cache. This in turn speeds up DNS responses.
Some ISP’s block access to websites by DNS spoo壬�ng. Setting up your own DNS server can help you
get around this. However, a more e��ective way to circumvent this type of censorship is by using the
tor browser (https://www.torproject.org/projects/torbrowser.html.en) which can be installed using the
sameersbn/browser-box (https://github.com/sameersbn/docker-browser-box) image.
Finally and most importantly, a local DNS server will enable you to de壬�ne a domain for your local
network. This allows you to address machines/services on the network with a name rather than its IP
address. When setting up web services whether you do it using docker or otherwise, installing a DNS
server makes the setup much simpler and easier to deal with.
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 1/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
In the above command the DNS server will only be accessible to the host and other containers over
the docker bridge interface (host only). If you want the DNS server to be accessible over the network
you should replace --publish=172.17.42.1:53:53/udp with --publish=53:53/udp (all interfaces) or
something like --publish=192.168.1.1:53:53/udp (speci壬�c interface).
From this point on 172.17.42.1 will refer to our local DNS server. Replace it with the appropriate
address depending on your setup.
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 2/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
If you prefer con壬�guring BIND by hand, you can turn o�� webmin startup by setting --
env='WEBMIN_ENABLED=false' in the run command. The BIND speci壬�c con壬�guration will be available
at /srv/docker/bind/bind . To apply your con壬�guration send the HUP signal to the container using
docker kill -s HUP bind
If everything works as expected the host command should return the IP address of
www.google.com .
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 3/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
1 domain-needed
2 all-servers
3 cache-size=5000
4 strict-order
5
6 server=/example.com/google.com/172.17.42.1
In the above example, regardless of the primary DNS con壬�guration the DNS server at 172.17.42.1
will be used to resolve example.com and google.com addresses. This is particularly useful in host
only con壬�gurations when you setup a domain to address various services on the local host without
having to manually change the DNS con壬�guration everytime you connect to a di��erent network.
After performing the dnsmasq con壬�guration the network manager needs to be restarted for the
changes to take e��ect. On Ubuntu, this is achieved using the command restart network-manager
Finally, we can con壬�gure docker such that the containers are automatically con壬�gured to use our
DNS server. This is done by adding --dns 172.17.42.1 to the docker daemon command. On
Ubuntu, this is done at /etc/default/docker . The docker daemon needs to be restarted for these
changes to take e��ect.
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 4/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
This is where we will perform the DNS con壬�guration. Changes to the con壬�guration can be applied
using the Apply Con壬�guration link in the top right corner of the page. We will create a domain named
example.com for demonstration purposes.
We start by creating the reverse zone 172.17.42.1 . This is optional and required only if you want to
be able to do reverse DNS (rDNS) lookups. A rDNS lookup returns the domain name that is
associated with a given IP address. To create the zone select Create master zone and in the Create
new zone dialog set the Zone type to Reverse, the Network address to your interface IP address
172.17.42.1 , the Master server to ns.example.com and 壬�nally set Email address to the domain
administrator’s email address and select Create.
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 5/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
Next, we create the forward zone example.com by selecting Create master zone and in the Create
new zone dialog set the Zone type to Forward, the Domain Name to example.com , the Master server
to ns.example.com and set Email address to the domain administrator’s email address and select
Create. Next, create the DNS entry for ns.example.com pointing to 172.17.42.1 and apply the
con壬�guration.
To complete this tutorial we will create a address (A) entry for webserver.example.com and then add
a domain name alias (CNAME) entry www.example.com which will point to webserver.example.com .
To create the A entry, select the zone example.com and then select the Address option. Set the
Name to webserver and the Address to 192.168.1.1 . To create the CNAME entry, select the zone
example.com and then select the Name Alias option. Set the Name to www and the Real Name to
webserver and apply the con壬�guration.
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 6/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
These commands should return the DNS addresses as per our con壬�guration. Time to 壬�nd out.
And there you have it. A local DNS server with a local domain named example.com .
If you found this post useful don’t forget to share it with your friends.
← Older (/blog/2014/10/31/hello-world/)
Join the discussion…
WooDzu • 2 years ago
Very nice read and a good use case for local RaspberyPI.
1 △ ▽ • Reply • Share ›
Mark • 2 years ago
Excellent writeup. It also helped me realise the potential of Docker much more.
But for the love of god: Please tell me what software you used for these gif's???
;)
1 △ ▽ • Reply • Share ›
I used kazam to capture the screen area and used mplayer to spit out the frames from the
video using: mplayer ao null videofilename vo jpeg:outdir=output
Then I manually (optional) deleted the frames that I did not want or thought are redundant
(a.k.a editing). Gnome Image Viewer works great for this, just press delete key when you want
to delete the current picture.
Next I created the gif using imagemagick: convert output/* output.gif
And finally optimized the size of the gif using: convert output.gif fuzz 10% layers Optimize
optimised.gif
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 7/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
optimised.gif
fuzz can be adjusted for quality over quantity.
2 △ ▽ • Reply • Share ›
Mincă Daniel Andrei > Sameer Naik • a year ago
I suggest you use https://asciinema.org/ for recording terminal sessions, it's quite a
good tool :) I've been using it myself for 2 weeks and, the thing is, it's so darn easy to
install via aptitude.
△ ▽ • Reply • Share ›
Gokhan Oner > Sameer Naik • 2 years ago
Hi Sameer , I did everything what you tell but both dns and webmin not working on my
Ubuntu 14.04. What can i do with this case ?
△ ▽ • Reply • Share ›
I suggest you open a issue/support request at
https://github.com/sameersbn/d.... Don't forget to mention the issue you are
facing and your setup details.
△ ▽ • Reply • Share ›
Sanjay Arora • 3 months ago
Sameer, any Ansible Playbook for this?
△ ▽ • Reply • Share ›
echeadle • 4 months ago
I tried the to setup the reverse zone as shown here. I could not get it to work. When creating a reverse
zone, you need to put in the network portion of your address. Which in your case I think is 192.168.1
Instead in the instructions, you put in your Server's address.
For my network, my router ip is 10.0.0.1 my dns server ip is 10.0.0.121. It is a home network so the
netmask is 255.255.255.0. This makes my network: 10.0.0 This worked great. Reverse pointers are
updated when I create the primary record and the host command works with the ip address.
I am using your container because it easily updates the dns records for my home network I am also
thinkig about using the same technique to create a home mail server.
This container is a lot of fun. Thanks for creating it.
△ ▽ • Reply • Share ›
Sanjay • a year ago
Very detailed and informative article! Thanks a lot!
△ ▽ • Reply • Share ›
Ove Ranheim • a year ago
I am not able to have my container to resolve the hostname for configured DNS IP.
Here is what I do: https://gist.github.com/oranhe...
I'm running ubuntu 14.04 LTS and docker bridge0 is configured by default to 172.17.0.0/16
Please advise.
△ ▽ Reply Share ›
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 8/9
2/26/2017 Deploying a DNS Server using Docker SAMEER NAIK
△ ▽ • Reply • Share ›
ip512 • a year ago
Thank you for this excellent article.
Note if you use docker 1.9+, the ip will be 172.17.0.1 instead of legacy 172.17.42.1
△ ▽ • Reply • Share ›
Navin • a year ago
I keep getting connection refused when I usepublish=53:53/udp! How do I solve this. Looks like bind
is still listening to 127.0.0.1 inside the container.
△ ▽ • Reply • Share ›
Bruno Batista • 2 years ago
Excellent content! Thanks!
△ ▽ • Reply • Share ›
Slind14 • 2 years ago
dang is there any unix os interface with such window head's?
△ ▽ • Reply • Share ›
http://www.damagehead.com/blog/2015/04/28/deployingadnsserverusingdocker/ 9/9