2

I've set up an ESP8266 (Wemos D1 Mini) to get IP-information via DHCP. Everything works fine and I can print the information :

Serial.print(WiFi.macAddress()); Serial.print(WiFI.localIP()); Serial.print(WiFi.subnetMask()); Serial.print(WiFi.gateway.IP());

But how do I print the DNS-address ??

I cant find a function for this ???

/Kind regards : Gurra

1

1 Answer 1

5
Serial.println(WiFi.dnsIP());

If you have more than one DNS server you can specify the index:

Serial.println(WiFi.dnsIP(1));
2
  • 1
    Thanks Majenko, i've Googled this question and found answers to ip, netmask, mac & gateway but not DNS, so you saved me hours of extra work by this....So I am very grateful !!
    – Rhino
    Commented May 1, 2019 at 10:49
  • 1
    You're welcome. You can find all the functions in the ESP8266WiFiSTA.h header file.
    – Majenko
    Commented May 1, 2019 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.