-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DNS lookup failed, last netif doesn't have a DNS server (IDFGH-6421) #8080
Comments
Hi @wowaz DNS servers are configured globally in lwip, they don't belong to specific interfaces. My guess is that the DNS server set by the DHCP client on WiFi station would not work on the ethernet subnet. esp_netif_dns_info_t gdns1, gdns2, gdns3;
ESP_ERROR_CHECK(esp_netif_get_dns_info(eth_netif, ESP_NETIF_DNS_MAIN, &gdns1));
ESP_ERROR_CHECK(esp_netif_get_dns_info(eth_netif, ESP_NETIF_DNS_BACKUP, &gdns2));
ESP_ERROR_CHECK(esp_netif_get_dns_info(eth_netif, ESP_NETIF_DNS_FALLBACK, &gdns3));
ESP_LOGI(TAG, "DNS servers : " IPSTR " , " IPSTR " , " IPSTR,
IP2STR(&gdns1.ip.u_addr.ip4),
IP2STR(&gdns2.ip.u_addr.ip4),
IP2STR(&gdns3.ip.u_addr.ip4)); |
Before eth init:
After eth init:
ESP-NETIF as abstraction-layer could store the DNS information for each interface, go through all interfaces in the route_prio order and change the DNS server before trying to resolve the name. |
@wowaz You're right, the DNS info is cleared in ESP-NETIF for interfaces with configured DHCP client, which is true for the predefined ethernet netif. esp-idf/components/esp_netif/lwip/esp_netif_lwip.c Lines 1555 to 1557 in 1c82e6e
Could you please try to disable the // Create new default instance of esp-netif for Ethernet
- esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
+ esp_netif_inherent_config_t custom_eth_config = ESP_NETIF_INHERENT_DEFAULT_ETH();
+ custom_eth_config.flags &= ~ESP_NETIF_DHCP_CLIENT;
+ esp_netif_config_t cfg = {
+ .base = &custom_eth_config,
+ .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH
+ };
esp_netif_t *eth_netif = esp_netif_new(&cfg); |
@david-cermak well this could help with the example above, but not if both, wifi sta and eth, are DHPC clients. |
@wowaz As mentioned in the first post, DNS servers are set globally in LWIP and IDF relies on this functionality, so this is currently a limitation we have to cope with. If you have any specific use-case, please describe it here, so we can discuss it and come up with a proposal, solution or a workaround as we did for the STA + ETH scenario. If you're looking for a general solution, could you please close this issue and subscribe here #6270 ? |
@david-cermak Sorry, don't get me wrong, i appreciate your help. The Issue you posted is really interesting. My use-case is pretty complex. The Ethernet and Wifi interface can switch between DHCP Client and static IP. The simplest option probably would be listening on all The best option for me is probably trying to implement the patch described in the other issue. But instead only using the default netif, i'll going through all available. This way no other changes in the whole project are necessary. Let's see how many obstacles i'll have to face to. 😄 |
@wowaz Any update on this issue? Have you succeeded in any of the proposed options? I'm sorry, there's no update from our side, as you can see in the referenced issue. |
Thanks for reporting, will close due to short of feedback, feel free to reopen with more updates. Thanks. |
Environment
Problem Description
If more than one interface is present it seems the dnslookup uses the newest to resolve the name, even if the interface doesn't have an DNS-Server.
Expected Behavior
Dnslookup tries to resolve the name with every interface until success.
Actual Behavior
Dnslookup seems only trying to resolve the name with the latest interface.
Steps to reproduce
Debug Logs
The text was updated successfully, but these errors were encountered: