Function esp_idf_sys::esp_netif_set_dns_info

source ·
pub unsafe extern "C" fn esp_netif_set_dns_info(
    esp_netif: *mut esp_netif_t,
    type_: esp_netif_dns_type_t,
    dns: *mut esp_netif_dns_info_t,
) -> esp_err_t
Expand description

@brief Set DNS Server information

This function behaves differently if DHCP server or client is enabled

If DHCP client is enabled, main and backup DNS servers will be updated automatically from the DHCP lease if the relevant DHCP options are set. Fallback DNS Server is never updated from the DHCP lease and is designed to be set via this API. If DHCP client is disabled, all DNS server types can be set via this API only.

Note that LWIP stores DNS server information globally, not per interface, so the first parameter is unused in the default LWIP configuration. If CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=1 this API sets internal DNS server information per netif. It’s also possible to set the global DNS server info by supplying esp_netif=NULL

If DHCP server is enabled, the Main DNS Server setting is used by the DHCP server to provide a DNS Server option to DHCP clients (Wi-Fi stations).

  • The default Main DNS server is typically the IP of the DHCP server itself.
  • This function can override it by setting server type ESP_NETIF_DNS_MAIN.
  • Other DNS Server types are not supported for the DHCP server.
  • To propagate the DNS info to client, please stop the DHCP server before using this API.

@param[in] esp_netif Handle to esp-netif instance @param[in] type Type of DNS Server to set: ESP_NETIF_DNS_MAIN, ESP_NETIF_DNS_BACKUP, ESP_NETIF_DNS_FALLBACK @param[in] dns DNS Server address to set

@return - ESP_OK on success - ESP_ERR_ESP_NETIF_INVALID_PARAMS invalid params