2018-03-25 12:35:05 +00:00
|
|
|
.. _global_configuration_auto_dns:
|
|
|
|
|
|
|
|
********
|
|
|
|
Auto-DNS
|
|
|
|
********
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
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::
|
2018-06-03 18:45:01 +00:00
|
|
|
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 :ref:`env_host_port_bind`.
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
**Table of Contents**
|
|
|
|
|
|
|
|
.. contents:: :local:
|
|
|
|
|
|
|
|
|
|
|
|
Native Docker
|
|
|
|
=============
|
|
|
|
|
2018-03-28 07:08:53 +00:00
|
|
|
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).
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
* Ensure :ref:`env_local_listen_addr` is set accordingly
|
|
|
|
* Ensure :ref:`env_host_port_bind` is set accordingly
|
|
|
|
* No other DNS resolver should listen on ``127.0.0.1:53``
|
|
|
|
|
|
|
|
|
2018-03-28 07:08:53 +00:00
|
|
|
Prerequisites
|
|
|
|
-------------
|
|
|
|
|
|
|
|
First ensure that :ref:`env_local_listen_addr` is either empty or listening on ``127.0.0.1``.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2018-06-03 18:45:01 +00:00
|
|
|
:caption: .env
|
|
|
|
:emphasize-lines: 3
|
2018-03-28 07:08:53 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
host> cd path/to/devilbox
|
|
|
|
host> vi .env
|
|
|
|
LOCAL_LISTEN_ADDR=
|
2018-03-28 07:08:53 +00:00
|
|
|
|
|
|
|
Then you need to ensure that :ref:`env_host_port_bind` is set to ``53``.
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
2018-06-03 18:45:01 +00:00
|
|
|
:caption: .env
|
|
|
|
:emphasize-lines: 3
|
2018-03-27 07:10:07 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
host> cd path/to/devilbox
|
|
|
|
host> vi .env
|
|
|
|
HOST_PORT_BIND=53
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
Before starting up the Devilbox, ensure that port ``53`` is not already used on ``127.0.0.1``.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2018-06-03 18:45:01 +00:00
|
|
|
:emphasize-lines: 2
|
2018-03-27 07:10:07 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
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
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
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``.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
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
|
2018-03-27 07:10:07 +00:00
|
|
|
|
2018-03-28 07:08:53 +00:00
|
|
|
|
|
|
|
Linux
|
|
|
|
-----
|
|
|
|
|
2018-05-08 07:06:10 +00:00
|
|
|
On Linux the DNS settings can be controlled by various different methods. Two of them are via
|
|
|
|
Network Manager and systemd-resolved. Choose on of the methods depending on your local setup.
|
|
|
|
|
|
|
|
Network Manager
|
|
|
|
^^^^^^^^^^^^^^^
|
|
|
|
|
2018-04-28 10:17:07 +00:00
|
|
|
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``:
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
2018-06-03 18:45:01 +00:00
|
|
|
:caption: /etc/dhcp/dhclient.conf
|
2018-03-27 07:10:07 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
prepend domain-name-servers 127.0.0.1;
|
2018-03-27 07:10:07 +00:00
|
|
|
|
2018-04-28 10:17:07 +00:00
|
|
|
When you do that for the first time, you need to restart the ``network-manager`` service.
|
2018-03-27 07:10:07 +00:00
|
|
|
|
2018-04-28 10:17:07 +00:00
|
|
|
.. code-block:: bash
|
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# Via service command
|
|
|
|
host> sudo service network-manager restart
|
2018-04-28 10:17:07 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# Or the systemd way
|
|
|
|
host> sudo systemctl restart network-manager
|
2018-04-28 10:17:07 +00:00
|
|
|
|
|
|
|
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``.
|
2018-03-27 07:10:07 +00:00
|
|
|
|
|
|
|
|
2018-05-08 07:06:10 +00:00
|
|
|
systemd-resolved
|
|
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
In case you are using systemd-resolved instead of NetworkManager, add the following line to
|
|
|
|
the very beginning to ``/etc/resolv.conf.head``:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2018-06-03 18:45:01 +00:00
|
|
|
:caption: /etc/resolv.conf.head
|
2018-05-08 07:06:10 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
nameserver 127.0.0.1
|
2018-05-08 07:06:10 +00:00
|
|
|
|
|
|
|
Prevent NetworkManager from modifying ``/etc/resolv.conf`` and leave everything to
|
|
|
|
systemd-resolved by adding the following line under the ``[main]`` section of
|
|
|
|
``/etc/NetworkManager/NetworkManager.conf``
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2018-06-03 18:45:01 +00:00
|
|
|
:caption: /etc/NetworkManager/NetworkManager.conf
|
2018-05-08 07:06:10 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
dns=none
|
2018-05-08 07:06:10 +00:00
|
|
|
|
|
|
|
As a last step you will have to restart ``systemd-resolved``.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
host> sudo systemctl stop systemd-resolved
|
|
|
|
host> sudo systemctl start systemd-resolved
|
2018-05-08 07:06:10 +00:00
|
|
|
|
|
|
|
Once done, you can verify if the new DNS settings are effective:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
host> systemd-resolve --status
|
2018-05-08 07:06:10 +00:00
|
|
|
|
2018-06-30 15:36:11 +00:00
|
|
|
.. seealso:: `Archlinux Wiki: resolv.conf <https://wiki.archlinux.org/index.php/Dhcpcd#resolv.conf>`_
|
2018-05-08 07:06:10 +00:00
|
|
|
|
2018-03-27 07:10:07 +00:00
|
|
|
|
2018-03-28 07:08:53 +00:00
|
|
|
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:: /_static/img/auto-dns-macos-dns.png
|
|
|
|
|
|
|
|
|
|
|
|
Windows
|
|
|
|
-------
|
|
|
|
|
|
|
|
On Windows, you need to change your active network adapter. See the following screenshots
|
|
|
|
for how to do it.
|
|
|
|
|
|
|
|
.. image:: /_static/img/auto-dns-windows-dns-01.jpg
|
|
|
|
.. image:: /_static/img/auto-dns-windows-dns-02.jpg
|
|
|
|
.. image:: /_static/img/auto-dns-windows-dns-03.jpg
|
|
|
|
|
|
|
|
In the last screenshot, you will have to add ``127.0.0.1`` as your ``Preferred DNS server``.
|
|
|
|
|
|
|
|
|
2018-03-27 07:10:07 +00:00
|
|
|
Docker Toolbox
|
|
|
|
==============
|
2018-03-28 07:08:53 +00:00
|
|
|
|
|
|
|
.. seealso:: :ref:`docker_toolbox`
|
|
|
|
|
|
|
|
MacOS
|
|
|
|
-----
|
|
|
|
|
|
|
|
* :ref:`env_local_listen_addr` must be empty in order to listen on all interfaces
|
|
|
|
* :ref:`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
|
|
|
|
|
|
|
|
.. todo:: This section needs further proof and information.
|
|
|
|
|
|
|
|
|
|
|
|
Windows
|
|
|
|
--------
|
|
|
|
|
|
|
|
* :ref:`env_local_listen_addr` must be empty in order to listen on all interfaces
|
|
|
|
* :ref:`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
|
|
|
|
|
|
|
|
.. todo:: This section needs further proof and information.
|