zephyr/samples/net/dns_resolve
Sebastian Bøe 55ee53ce91 cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts
Prepend the text 'cmake_minimum_required(VERSION 3.8.2)' into the
application and test build scripts.

Modern versions of CMake will spam users with a deprecation warning
when the toplevel CMakeLists.txt does not specify a CMake
version. This is documented in bug #8355.

To resolve this we include a cmake_minimum_required() line into the
toplevel build scripts. Additionally, cmake_minimum_required is
invoked from within boilerplate.cmake. The highest version will be
enforced.

This patch allows us to afterwards change CMake policy CMP000 from OLD
to NEW which in turn finally rids us of the verbose warning.

The extra boilerplate is considered more acceptable than the verbosity
of the CMP0000 policy.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
..
src net: config: Rename Kconfig options to correspond to library name 2018-08-13 18:42:31 -07:00
CMakeLists.txt cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts 2018-08-15 04:06:50 -07:00
README.rst net: config: Rename Kconfig options to correspond to library name 2018-08-13 18:42:31 -07:00
prj.conf net: config: Rename Kconfig options to correspond to library name 2018-08-13 18:42:31 -07:00
sample.yaml samples: net: dns: Add LLMNR client support to DNS resolver 2018-06-29 13:11:18 +03:00

README.rst

.. _dns-resolve-sample:

DNS Resolve Application
#######################

Overview
********

The DNS resolver sample application implements a basic DNS resolver according
to RFC 1035. Supported DNS answers are IPv4/IPv6 addresses and CNAME.

If a CNAME is received, the DNS resolver will create another DNS query.
The number of additional queries is controlled by the
DNS_RESOLVER_ADDITIONAL_QUERIES Kconfig variable.

The multicast DNS (mDNS) client resolver support can be enabled by setting
:option:`CONFIG_MDNS_RESOLVER` Kconfig option.
See https://tools.ietf.org/html/rfc6762 for more details about mDNS.

The link-local multicast name resolution (LLMNR) client resolver support can be
enabled by setting the :option:`CONFIG_LLMNR_RESOLVER` Kconfig option.
See https://tools.ietf.org/html/rfc4795 for more details about LLMNR.

For more information about DNS configuration variables, see:
:file:`subsys/net/lib/dns/Kconfig`. The DNS resolver API can be found at
:file:`include/net/dns_resolve.h`. The sample code can be found at:
:file:`samples/net/dns_resolve`.

Requirements
************

- :ref:`networking_with_qemu`

- screen terminal emulator or equivalent.

- For the Arduino 101 board, the ENC28J60 Ethernet module is required.

- dnsmasq application. The dnsmasq version used in this sample is:

.. code-block:: console

    dnsmasq -v
    Dnsmasq version 2.76  Copyright (c) 2000-2016 Simon Kelley

Building and Running
********************

Network Configuration
=====================

Open the project configuration file for your platform, for example:
:file:`prj_frdm_k64f.conf` is the configuration file for the
:ref:`frdm_k64f` board.

In this sample application, both static or DHCPv4 IP addresses are supported.
Static IP addresses are specified in the project configuration file,
for example:

.. code-block:: console

	CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
	CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"

are the IPv6 addresses for the DNS client running Zephyr and the DNS server,
respectively.

DNS server
==========

The dnsmasq tool may be used for testing purposes. Sample dnsmasq start
script can be downloaded from the zephyrproject-rtos/net-tools project area:
https://github.com/zephyrproject-rtos/net-tools

Open a terminal window and type:

.. code-block:: console

    $ cd net-tools
    $ sudo ./dnsmasq.sh

The default project configurations settings for this sample uses the public
Google DNS servers.  In order to use the local dnsmasq server, please edit
the appropriate 'prj.conf' file and update the DNS server addresses.  For
instance, if using the usual IP addresses assigned to testing, update them
to the following values:

.. code-block:: console

    CONFIG_DNS_SERVER1="192.0.2.2:5353"
    CONFIG_DNS_SERVER2="[2001:db8::2]:5353"

.. note::
    DNS uses port 53 by default, but the dnsmasq.conf file provided by
    net-tools uses port 5353 to allow executing the daemon without
    superuser privileges.

If dnsmasq fails to start with an error like this:

.. code-block:: console

    dnsmasq: failed to create listening socket for port 5353: Address already in use

Open a terminal window and type:

.. code-block:: console

    $ killall -s KILL dnsmasq

Try to launch the dnsmasq application again.

For testing mDNS, use Avahi script in net-tools project:

.. code-block:: console

    $ cd net-tools
    $ ./avahi-daemon.sh


LLMNR Responder
===============

If you want Zephyr to respond to a LLMNR DNS request that Windows host is
sending, then following config options could be set:

.. code-block:: console

    CONFIG_NET_HOSTNAME_ENABLE=y
    CONFIG_NET_HOSTNAME="zephyr-device"
    CONFIG_DNS_RESOLVER=y
    CONFIG_LLMNR_RESPONDER=y

A Zephyr host needs a hostname assigned to it so that it can respond to a DNS
query. Note that the hostname should not have any dots in it.


QEMU x86
========

To use QEMU for testing, follow the :ref:`networking_with_qemu` guide.


FRDM K64F
=========

Open a terminal window and type:

.. zephyr-app-commands::
   :zephyr-app: samples/net/dns_resolve
   :board: frdm_k64f
   :goals: build flash
   :compact:

See :ref:`Freedom-K64F board documentation <frdm_k64f>` for more information
about this board.

Open a terminal window and type:

.. code-block:: console

    $ screen /dev/ttyACM0 115200


Use 'dmesg' to find the right USB device.

Once the binary is loaded into the FRDM board, press the RESET button.

Arduino 101
===========

Open a terminal window and type:

.. zephyr-app-commands::
   :zephyr-app: samples/net/dns_resolve
   :board: arduino_101
   :goals: build
   :compact:

To load the binary in the development board follow the steps
in :ref:`arduino_101`.

Open a terminal window and type:

.. code-block:: console

    $ screen /dev/ttyUSB0 115200


Use 'dmesg' to find the right USB device.

Once the binary is loaded into the Arduino 101 board, press the RESET button.

The ENC28J60 module is an Ethernet device with SPI interface.
The following pins must be connected from the ENC28J60 device to the
Arduino 101 board:

===========    ===================================
Arduino 101    ENC28J60 (pin numbers on the board)
===========    ===================================
D13            SCK  (1)
D12            SO   (3)
D11            SI   (2)
D10            CS   (7)
D04            INT  (5)
3.3V           VCC  (10)
GDN            GND  (9)
===========    ===================================