1.. _dns-resolve-sample: 2 3DNS Resolve Application 4####################### 5 6Overview 7******** 8 9This application will setup IP address for the device, and then 10try to resolve various hostnames according to how the user has 11configured the system. 12 13- If IPv4 is enabled, then A record for ``www.zephyrproject.org`` is 14 resolved. 15- If IPv6 is enabled, then AAAA record for ``www.zephyrproject.org`` is 16 resolved. 17- If mDNS is enabled, then ``zephyr.local`` name is resolved. 18 19Requirements 20************ 21 22- :ref:`networking_with_host` 23 24- screen terminal emulator or equivalent. 25 26- For most boards without ethernet, the ENC28J60 Ethernet module is required. 27 28- dnsmasq application. The dnsmasq version used in this sample is: 29 30.. code-block:: console 31 32 dnsmasq -v 33 Dnsmasq version 2.76 Copyright (c) 2000-2016 Simon Kelley 34 35Building and Running 36******************** 37 38Network Configuration 39===================== 40 41Open the project configuration file for your platform, for example: 42:file:`prj_frdm_k64f.conf` is the configuration file for the 43:ref:`frdm_k64f` board. 44 45In this sample application, both static or DHCPv4 IP addresses are supported. 46Static IP addresses are specified in the project configuration file, 47for example: 48 49.. code-block:: console 50 51 CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1" 52 CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2" 53 54are the IPv6 addresses for the DNS client running Zephyr and the DNS server, 55respectively. 56 57DNS server 58========== 59 60The dnsmasq tool may be used for testing purposes. Sample dnsmasq start 61script can be downloaded from the zephyrproject-rtos/net-tools project area: 62https://github.com/zephyrproject-rtos/net-tools 63 64Open a terminal window and type: 65 66.. code-block:: console 67 68 $ cd net-tools 69 $ sudo ./dnsmasq.sh 70 71The default project configurations settings for this sample uses the public 72Google DNS servers. In order to use the local dnsmasq server, please edit 73the appropriate 'prj.conf' file and update the DNS server addresses. For 74instance, if using the usual IP addresses assigned to testing, update them 75to the following values: 76 77.. code-block:: console 78 79 CONFIG_DNS_SERVER1="192.0.2.2:5353" 80 CONFIG_DNS_SERVER2="[2001:db8::2]:5353" 81 82.. note:: 83 DNS uses port 53 by default, but the dnsmasq.conf file provided by 84 net-tools uses port 5353 to allow executing the daemon without 85 superuser privileges. 86 87If dnsmasq fails to start with an error like this: 88 89.. code-block:: console 90 91 dnsmasq: failed to create listening socket for port 5353: Address already in use 92 93Open a terminal window and type: 94 95.. code-block:: console 96 97 $ killall -s KILL dnsmasq 98 99Try to launch the dnsmasq application again. 100 101For testing mDNS, use Avahi script in net-tools project: 102 103.. code-block:: console 104 105 $ cd net-tools 106 $ ./avahi-daemon.sh 107 108 109LLMNR Responder 110=============== 111 112If you want Zephyr to respond to a LLMNR DNS request that Windows host is 113sending, then following config options could be set: 114 115.. code-block:: console 116 117 CONFIG_NET_HOSTNAME_ENABLE=y 118 CONFIG_NET_HOSTNAME="zephyr-device" 119 CONFIG_DNS_RESOLVER=y 120 CONFIG_LLMNR_RESPONDER=y 121 122A Zephyr host needs a hostname assigned to it so that it can respond to a DNS 123query. Note that the hostname should not have any dots in it. 124 125 126QEMU x86 127======== 128 129To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. 130 131 132FRDM K64F 133========= 134 135Open a terminal window and type: 136 137.. zephyr-app-commands:: 138 :zephyr-app: samples/net/dns_resolve 139 :board: frdm_k64f 140 :goals: build flash 141 :compact: 142 143See :ref:`Freedom-K64F board documentation <frdm_k64f>` for more information 144about this board. 145 146Open a terminal window and type: 147 148.. code-block:: console 149 150 $ screen /dev/ttyACM0 115200 151 152 153Use 'dmesg' to find the right USB device. 154 155Once the binary is loaded into the FRDM board, press the RESET button. 156