devilbox/docs/intermediate/setup-auto-dns.rst

154 lines
4.4 KiB
ReStructuredText
Raw Normal View History

.. include:: /_includes/snippets/__ANNOUNCEMENTS__.rst
2018-07-03 13:47:58 +00:00
.. _setup_auto_dns:
2018-03-25 12:35:05 +00:00
2018-07-03 13:47:58 +00:00
**************
Setup Auto DNS
**************
2018-03-27 07:10:07 +00:00
2018-07-08 10:23:57 +00:00
If you don't want to add host records manually for every project, you can also use the bundled
2018-03-27 07:10:07 +00:00
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.
2018-03-27 07:10:07 +00:00
.. 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
2018-07-08 10:23:57 +00:00
Docker on Linux
---------------
2018-03-28 07:08:53 +00:00
2018-07-08 10:23:57 +00:00
Your DNS server IP address is ``127.0.0.1``.
2018-05-08 07:06:10 +00:00
2018-07-08 10:23:57 +00:00
.. seealso:: :ref:`howto_add_custom_dns_server_on_linux`
2018-05-08 07:06:10 +00:00
2018-07-08 10:23:57 +00:00
Docker for Mac
--------------
2018-03-27 07:10:07 +00:00
2018-07-08 10:23:57 +00:00
Your DNS server IP address is ``127.0.0.1``.
2018-07-08 10:23:57 +00:00
.. seealso:: :ref:`howto_add_custom_dns_server_on_mac`
2018-07-08 10:23:57 +00:00
Docker for Windows
------------------
2018-07-08 10:23:57 +00:00
Your DNS server IP address is ``127.0.0.1``.
2018-05-08 07:06:10 +00:00
2018-07-08 10:23:57 +00:00
.. seealso:: :ref:`howto_add_custom_dns_server_on_win`
2018-03-28 07:08:53 +00:00
2018-03-27 07:10:07 +00:00
Docker Toolbox
==============
2018-03-28 07:08:53 +00:00
2018-07-03 13:47:58 +00:00
.. seealso:: :ref:`howto_docker_toolbox_and_the_devilbox`
2018-03-28 07:08:53 +00:00
2018-07-06 07:30:52 +00:00
This part applies equally for Docker Toolbox on MacOS and on Windows:
Prerequisites
-------------
2018-03-28 07:08:53 +00:00
* :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``
2018-07-06 07:30:52 +00:00
You need to create three port-forwards to make the DNS and web server available on your host os:
2018-03-28 07:08:53 +00:00
* Port ``80`` from the Docker Toolbox virtual machine must be port-forwarded to ``127.0.0.1:80`` on your host os
2018-07-06 07:30:52 +00:00
* Port ``443`` from the Docker Toolbox virtual machine must be port-forwarded to ``127.0.0.1:443`` on your host os
2018-03-28 07:08:53 +00:00
* Port ``53`` from the Docker Toolbox virtual machine must be port-forwarded to ``127.0.0.1:53`` on your host os
2018-07-06 07:30:52 +00:00
Assuming the Docker Toolbox IP is ``192.168.99.100`` your forwards must be as follows:
2018-03-28 07:08:53 +00:00
2018-07-06 07:30:52 +00:00
+----------------+-----------+-----------+---------+
| 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 |
+----------------+-----------+-----------+---------+
2018-03-28 07:08:53 +00:00
2018-07-06 07:30:52 +00:00
.. seealso::
2018-07-12 18:57:46 +00:00
* :ref:`howto_ssh_port_forward_on_docker_toolbox_from_host`
2018-07-06 07:30:52 +00:00
* :ref:`howto_find_docker_toolbox_ip_address`
2018-03-28 07:08:53 +00:00
2018-07-06 07:30:52 +00:00
Actual setup
------------
.. important::
After settings this up, follow the above guides for **Docker for Mac** or **Docker for Windows**
to finish the setup.
2018-07-08 10:23:57 +00:00
2018-07-12 06:48:17 +00:00
..
Access for other network devices
2018-07-08 10:23:57 +00:00
2018-07-12 06:48:17 +00:00
..
seealso::
2018-07-08 10:23:57 +00:00
* :ref:`access_devilbox_from_android`
* :ref:`access_devilbox_from_iphone`
* :ref:`access_colleagues_devilbox`
* :ref:`shared_devilbox_server_in_lan`