devilbox/docs/configuration-global/auto-dns.rst
2018-04-14 10:17:25 +02:00

4.9 KiB

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 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

Linux

If the prerequisites are met, you can edit /etc/resolv.conf with root or sudo privileges and add the Devilbox DNS server line by adding a nameserver directive which points to 127.0.0.1:

host> sudi vi /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
nameserver 192.168.0.10
search local

Important

Keep all other nameserver entries intact. The Devilbox DNS nameserver will only work once the Devilbox is running. If you remove all others and don't run the Devilbox, you won't be able to resolve any DNS names anymore.

Important

The Devilbox nameserver entry should be the very first one.

If you now start the Devilbox you don't need to take care about manually adding DNS records anymore. Auto-DNS is now setup working.

MacOS

Modifying /etc/resolv.conf does not work on MacOS, you need to make changes in your System Preferences:

  1. Open System Preferences
  2. Go to Network
  3. Select your connected interface
  4. Click on DNS tab
  5. Add new DNS server by clicking the + sign
  6. Add 127.0.0.1

image

Windows

On Windows, you need to change your active network adapter. See the following screenshots for how to do it.

image

image

image

In the last screenshot, you will have to add 127.0.0.1 as your Preferred DNS server.

Docker Toolbox

docker_toolbox

MacOS

  • env_local_listen_addr must be empty in order to listen on all interfaces
  • env_host_port_bind must be set to 53
  • Port 80 from the Docker Toolbox virtual machine must be port-forwarded to 127.0.0.1:80 on your host os
  • Port 53 from the Docker Toolbox virtual machine must be port-forwarded to 127.0.0.1:53 on your host os

This section needs further proof and information.

Windows

  • env_local_listen_addr must be empty in order to listen on all interfaces
  • env_host_port_bind must be set to 53
  • Port 80 from the Docker Toolbox virtual machine must be port-forwarded to 127.0.0.1:80 on your host os
  • Port 53 from the Docker Toolbox virtual machine must be port-forwarded to 127.0.0.1:53 on your host os

This section needs further proof and information.