A small async DNS client for MicroPython
- Works on
ESP32
,ESP8266
,Raspberry Pi Pico W
,WM W600
and other boards - Versatile, runs multiple queries at a time using multiple DNS servers
- Supports IPv4 and IPv6
- Supports
mDNS
(Multicast DNS) name resolution - Works with WiFi, Ethernet, Cellular, and in multi-network scenarios
- Caches up to 32 hostnames (configurable)
- API-compatible with
getaddrinfo
Using CLI:
mpremote mip install github:vshymanskyy/aiodns
Using REPL (your board must be connected to the internet):
import mip
mip.install("github:vshymanskyy/aiodns")
See usage examples
aiodns.servers = set(["8.8.8.8", "1.1.1.1"])
aiodns.servers.add("9.9.9.9")
aiodns.timeout_ms = 5000
aiodns.cache.clear()
aiodns.cache_size = 32
await aiodns.getaddrinfo(hostname, port, family=AF_INET, type=0, proto=0, flags=0)
pip3 install -U python-minifier mpy-cross
python3 ./extra/build.py
Output:
Minified: 2796 bytes
Compiled: 2202 bytes
export MICROPYPATH=".frozen:./lib:."
mkdir -p lib
micropython -m mip install logging
micropython examples/simple/main.py
pip3 install -U microemu
microemu examples/simple/main.py