Auto-DNS¶
If you don’t want to add DNS records manually for every project, you can also use the bundled DNS server and use it’s DNS catch-all feature to have all DNS records automatically available.
Important
By default, the DNS server is set to listen on 1053
to avoid port collisions during startup.
You need to change it to 53
in .env
via HOST_PORT_BIND.
Table of Contents
Native Docker¶
The webserver as well as the DNS server must be available on 127.0.0.1
or on all interfaces
on 0.0.0.0
. Additionally the DNS server port must be set to 53
(it is not by default).
- Ensure LOCAL_LISTEN_ADDR is set accordingly
- Ensure HOST_PORT_BIND is set accordingly
- No other DNS resolver should listen on
127.0.0.1:53
Prerequisites¶
First ensure that LOCAL_LISTEN_ADDR is either empty or listening on 127.0.0.1
.
host> cd path/to/devilbox
host> vi .env
LOCAL_LISTEN_ADDR=
Then you need to ensure that HOST_PORT_BIND is set to 53
.
host> cd path/to/devilbox
host> vi .env
HOST_PORT_BIND=53
Before starting up the Devilbox, ensure that port 53
is not already used on 127.0.0.1
.
host> netstat -an | grep -E 'LISTEN\s*$'
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:43477 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:50267 0.0.0.0:* LISTEN
If you see port 53
already being used as in the above example, ensure to stop any
DNS resolver, otherwise it does not work.
The output should look like this (It is only important that there is no :53
.
host> netstat -an | grep -E 'LISTEN\s*$'
tcp 0 0 127.0.0.1:43477 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:50267 0.0.0.0:* LISTEN
Linux¶
If the prerequisites are met, you can edit /etc/dhcp/dhclient.conf
with root or sudo privileges
and add an instruction, which tells your local DHCP client that whenever any of your DNS servers
are changed, you always want to have an additional entry, which is the one from the Devilbox.
Add the following line to to the very beginning to /etc/dhcp/dhclient.conf
:
prepend domain-name-servers 127.0.0.1;
When you do that for the first time, you need to restart the network-manager
service.
# Via service command
$ sudo service network-manager restart
# Or the systemd way
$ sudo systemctl restart network-manager
This will make sure that whenever your /etc/resolv.conf is deployed, you will have 127.0.0.1
as the first entry and also make use of any other DNS server which are deployed via the LAN’s DHCP server.
If the Devilbox DNS server is not running, it does not affect the name resolution, because you will
still have other entries in /etc/resolv.conf
.
Docker Toolbox¶
See also
MacOS¶
- LOCAL_LISTEN_ADDR must be empty in order to listen on all interfaces
- HOST_PORT_BIND must be set to
53
- Port
80
from the Docker Toolbox virtual machine must be port-forwarded to127.0.0.1:80
on your host os - Port
53
from the Docker Toolbox virtual machine must be port-forwarded to127.0.0.1:53
on your host os
Todo
This section needs further proof and information.
Windows¶
- LOCAL_LISTEN_ADDR must be empty in order to listen on all interfaces
- HOST_PORT_BIND must be set to
53
- Port
80
from the Docker Toolbox virtual machine must be port-forwarded to127.0.0.1:80
on your host os - Port
53
from the Docker Toolbox virtual machine must be port-forwarded to127.0.0.1:53
on your host os
Todo
This section needs further proof and information.