From 1bdb542e504d345226a9bd5059db2608f7d8eb00 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 11 Dec 2022 16:24:14 +0100 Subject: [PATCH 1/2] Fix IPv4 DNS resolution when IPv6 is enabled --- tasmota/tasmota_support/support_wifi.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index b72c309cd..81e4de039 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -893,6 +893,9 @@ bool WifiHostByName(const char* aHostname, IPAddress& aResult) { } #else // DnsClient can't do one-shot mDNS queries so use WiFi.hostByName() for *.local +#ifdef USE_IPV6 + aResult.setV4(); // force IPv4 result for now, until DNS is updated to IPv6 +#endif size_t hostname_len = strlen(aHostname); if (strstr_P(aHostname, PSTR(".local")) == &aHostname[hostname_len] - 6) { if (WiFi.hostByName(aHostname, aResult)) { From bde58105d03c50c9072a5a6d96c489b6891752ab Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 11 Dec 2022 16:31:14 +0100 Subject: [PATCH 2/2] More universal way to force IPv4 --- tasmota/tasmota_support/support_wifi.ino | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index 81e4de039..5088ab81b 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -893,9 +893,7 @@ bool WifiHostByName(const char* aHostname, IPAddress& aResult) { } #else // DnsClient can't do one-shot mDNS queries so use WiFi.hostByName() for *.local -#ifdef USE_IPV6 - aResult.setV4(); // force IPv4 result for now, until DNS is updated to IPv6 -#endif + aResult = (uint32_t) 0x00000000L; // indirectly force to be IPv4, since the client touches the binary format later size_t hostname_len = strlen(aHostname); if (strstr_P(aHostname, PSTR(".local")) == &aHostname[hostname_len] - 6) { if (WiFi.hostByName(aHostname, aResult)) {