DNS Resolution In Thread Network
- 3 minutes read - 505 wordsIn previous articles, we explored communication between a Thread device and external (non-Thread) networks, primarily over TCP/HTTP using IP addresses and ports. However, in real-world applications, we rarely use raw IP addresses. Instead, we rely on hostnames — which are resolved to IP addresses using DNS (Domain Name System).
Public DNS resolution (like Google’s 8.8.8.8) handles global domain names, typically configured at the OS or browser level. But for private, local networks — like those used in IoT and Thread-based deployments — we need a local DNS setup to resolve custom hostnames (e.g., iot.gateway) within our own local/edge network.
In this article, we’ll walk through setting up a local DNS server and configuring it to work with a Thread network, enabling hostname resolution from Thread end devices to your IoT gateway.
🔧 Setting Up a Local DNS Server
Install and start dnsmasq following this guide.
brew install dnsmasq
sudo brew services start dnsmasq
This starts a lightweight DNS server that can map hostnames to IPs within your local network.
💡 To define custom hostnames, you can edit /usr/local/etc/dnsmasq.conf
and add entries point to a hosts file (like /etc/hosts
).
10.155.150.52 iot.gateway
We can also use NAMO dns for mac. Similarly we can setup on DNS server on other platforms (Raspberry PI).
We can test resolution in nslookup
or dig
commands.
➜ ~ nslookup iot.gateway 10.155.150.53
Server: 10.155.150.53
Address: 10.155.150.53#53
Name: iot.gateway
Address: 10.155.150.52
➜ ~
🌐 Thread Network Configuration
-
Set up a Border Router - Follow the Step 1 of article : Connecting Thread devices to Internet, and setup a border router on Raspberry Pi.
-
Start a thread network - Access border router’s web interface over http://borderrouter_ip , and Form a Thread network.
- Start Commissioner - Start a commissioner and joiner rule with a PSKd
- Enable SRP - Make sure SRP server is running on border router.
kuldeep@kuldeep:~ $ sudo ot-ctl srp server enable
Done
kuldeep@kuldeep:~ $ sudo ot-ctl srp server state
running
Done
Configure the Thread End Device (Joiner)
As explained in earlier article set up a thread end device nRF52840 dongle, with open thread cli firmware.
Screen into the dongle uart.
PC@PC:~ $ screen /dev/tty.usbmodemFC298E043841B1 115200
>
> ifconfig up
Done
> joiner start J01NME
Done
Joiner success
>
> thread start
Done
> state
child
Done
> state
router
Done
SRP Client must be running
> srp client autostart enable
Done
> srp client autostart
Enabled
Done
> srp client state
Enabled
Done
>
Configure DNS on the Thread Device
Set the DNS server to point to your local DNS server’s IP (e.g., 10.155.150.53
):
> dns config 10.155.150.53 53
Synthesized IPv6 DNS server address: fde2:5e3b:5bcb:2:0:0:a85:8235
Done
> dns config
Server: [fde2:5e3b:5bcb:2:0:0:a85:8235]:53
ResponseTimeout: 6000 ms
MaxTxAttempts: 3
RecursionDesired: yes
ServiceMode: srv_txt_opt
Nat64Mode: allow
Done
>
Resolve a Hostname
Assuming iot.gateway
is configured in your DNS server above setup is done.
Now test dns in thread device.
> dns resolve iot.gateway
DNS response for iot.gateway. - fde2:5e3b:5bcb:2:0:0:a85:8234 TTL:60
Done
>
🧠 API References (OpenThread):
otDnsClientGetDefaultConfig
otDnsClientResolveAddress
otDnsAddressResponseGetHostName
Find the IoT Practices Publication for more details.
#IOT #network #cloud #getting started #learning #technology #fundamentals #thread #openthread #security #nRF #dns #tcp