4.4 KiB
Setup Auto DNS
If you don't want to add host 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 env_host_port_bind
.
Table of Contents
- local
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
env_local_listen_addr
is set accordingly - Ensure
env_host_port_bind
is set accordingly - No other DNS resolver should listen on
127.0.0.1:53
Prerequisites
First ensure that env_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 env_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
Docker on Linux
Your DNS server IP address is 127.0.0.1
.
howto_add_custom_dns_server_on_linux
Docker for Mac
Your DNS server IP address is 127.0.0.1
.
howto_add_custom_dns_server_on_mac
Docker for Windows
Your DNS server IP address is 127.0.0.1
.
howto_add_custom_dns_server_on_win
Docker Toolbox
howto_docker_toolbox_and_the_devilbox
This part applies equally for Docker Toolbox on MacOS and on Windows:
Prerequisites
env_local_listen_addr
must be empty in order to listen on all interfacesenv_host_port_bind
must be set to53
You need to create three port-forwards to make the DNS and web server available on your host os:
- Port
80
from the Docker Toolbox virtual machine must be port-forwarded to127.0.0.1:80
on your host os - Port
443
from the Docker Toolbox virtual machine must be port-forwarded to127.0.0.1:443
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
Assuming the Docker Toolbox IP is 192.168.99.100
your forwards must be as follows:
From IP | From port | To IP | To port |
---|---|---|---|
192.168.99.100 | 53 | 127.0.0.1 | 53 |
192.168.99.100 | 80 | 127.0.0.1 | 80 |
192.168.99.100 | 443 | 127.0.0.1 | 443 |
* howto_ssh_port_forward_on_docker_toolbox_from_host
* howto_find_docker_toolbox_ip_address
Actual setup
Important
After settings this up, follow the above guides for Docker for Mac or Docker for Windows to finish the setup.