Part 1
요약·해설
Port 53·5353 차이, local server 설정, LLMNR hostname 제약과 10개 원문 command/config block을 보존합니다.
A · AAAA
mDNS · LLMNR
dnsmasq · Avahi
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
82059899295BB8D871FEC1169B5FB98EE1A0B15B6E06595A19E0FBEF7FADA157
.. zephyr:code-sample:: dns-resolve
:name: DNS resolve
:relevant-api: dns_resolve net_mgmt
Resolve an IP address for a given hostname.
Overview
********
This application will setup IP address for the device, and then
try to resolve various hostnames according to how the user has
configured the system.
- If IPv4 is enabled, then A record for ``www.zephyrproject.org`` is
resolved.
- If IPv6 is enabled, then AAAA record for ``www.zephyrproject.org`` is
resolved.
- If mDNS is enabled, then ``zephyr.local`` name is resolved.
Requirements
************
- :ref:`networking_with_host`
- screen terminal emulator or equivalent.
- For most boards without ethernet, 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:: cfg
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:: cfg
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:: cfg
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.
Part 3
한국어 전문 번역
개요
이 application은 device의 IP address를 설정한 뒤 사용자가 system을 구성한 방식에 따라 여러 hostname의 address를 resolve합니다.
- IPv4가 활성화되어 있으면
www.zephyrproject.org의 A record를 resolve합니다. - IPv6가 활성화되어 있으면
www.zephyrproject.org의 AAAA record를 resolve합니다. - mDNS가 활성화되어 있으면
zephyr.localname을 resolve합니다.
요구 사항
- Host와 network 연결
screenterminal emulator 또는 동등한 program- Ethernet이 없는 대부분의 board에서는 ENC28J60 Ethernet module
dnsmasqapplication
이 sample에서 사용한 dnsmasq version은 다음과 같습니다.
dnsmasq -v
Dnsmasq version 2.76 Copyright (c) 2000-2016 Simon Kelley
Build와 실행
Network 설정
Platform용 project configuration file을 엽니다. 예를 들어 prj_frdm_k64f.conf는 FRDM-K64F board용 configuration file입니다.
이 sample application은 static address와 DHCPv4 address를 모두 지원합니다. Static IP address는 project configuration file에 지정합니다. 다음 값은 Zephyr에서 실행되는 DNS client와 DNS server의 IPv6 address입니다.
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
DNS server
시험에는 dnsmasq tool을 사용할 수 있습니다. Sample dnsmasq 시작 script는 zephyrproject-rtos/net-tools project에서 받을 수 있습니다.
Terminal을 열고 다음 명령을 실행합니다.
$ cd net-tools
$ sudo ./dnsmasq.sh
이 sample의 기본 project configuration은 public Google DNS server를 사용합니다. Local dnsmasq server를 사용하려면 해당 prj.conf에서 DNS server address를 수정합니다. 일반적인 시험용 IP address를 사용한다면 다음 값으로 바꿉니다.
CONFIG_DNS_SERVER1="192.0.2.2:5353"
CONFIG_DNS_SERVER2="[2001:db8::2]:5353"
DNS의 기본 port는 53이지만 net-tools가 제공하는 dnsmasq.conf는 superuser privilege 없이 daemon을 실행할 수 있도록 port 5353을 사용합니다.
Dnsmasq가 다음과 같이 port 5353의 listening socket을 만들지 못한다면 이미 같은 port를 사용하는 process가 있는 것입니다.
dnsmasq: failed to create listening socket for port 5353: Address already in use
Terminal에서 기존 dnsmasq process를 종료합니다.
$ killall -s KILL dnsmasq
그다음 dnsmasq application을 다시 시작합니다. mDNS를 시험하려면 net-tools project의 Avahi script를 사용합니다.
$ cd net-tools
$ ./avahi-daemon.sh
LLMNR Responder
Windows host가 보내는 LLMNR DNS request에 Zephyr가 응답하도록 하려면 다음 configuration option을 설정할 수 있습니다.
CONFIG_NET_HOSTNAME_ENABLE=y
CONFIG_NET_HOSTNAME="zephyr-device"
CONFIG_DNS_RESOLVER=y
CONFIG_LLMNR_RESPONDER=y
Zephyr host가 DNS query에 응답하려면 hostname이 할당되어 있어야 합니다. Hostname에는 dot이 들어가면 안 됩니다.
QEMU x86
QEMU 시험 환경은 QEMU network 설정을 따릅니다.
FRDM-K64F
Terminal을 열어 FRDM-K64F용 application을 build하고 flash합니다.
west build -b frdm_k64f samples/net/dns_resolve
west flash
다른 terminal에서 board의 serial console을 엽니다.
$ screen /dev/ttyACM0 115200
올바른 USB device는 dmesg로 찾을 수 있습니다. Binary가 FRDM board에 load되면 RESET button을 누릅니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.