Setting DNS servers ...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Setting DNS servers ...

Postby kolban » Thu Nov 24, 2016 6:16 am

I may have missed some API ... but is there a way to specify the DNS servers that our ESP32 should use when it connects as a station? Where do the DNS server lists come from when we connect to an access point? Is it perhaps received as part of the DHCP protocols? What if we aren't using DHCP but instead configuring static IP addresses or simply want to specify our own DNS server names?

DNS is the Domain Name System which is the technology responsible for resolving character based domain names (eg. www.google.com) into their corresponding IP addresses.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

danicampora
Posts: 3
Joined: Mon Feb 29, 2016 2:38 am

Re: Setting DNS servers ...

Postby danicampora » Mon Nov 28, 2016 10:37 am

I am also interested about this. I have tried to use:

Code: Select all

dns_setserver()
without success. I also experience that whenever a static IP is configured, the ESP32 cannot access the internet anymore (although it is reachable on my local network). Anybody has ideas on this?

Cheers,
Daniel

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Setting DNS servers ...

Postby WiFive » Tue Nov 29, 2016 2:25 am

Well this is how dhcp does it:

Code: Select all

/* DNS servers */
  for (n = 0; (n < DNS_MAX_SERVERS) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n); n++) {
    ip_addr_t dns_addr;
    ip_addr_set_ip4_u32(&dns_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n)));
    dns_setserver(n, &dns_addr);
  }

Who is online

Users browsing this forum: nopnop2002 and 90 guests