Go Down

Topic: DHCP *AND* DNS with Ethernet Shield Library (Read 1 time) previous topic - next topic


DHCP  *AND*  DNS with Ethernet Shield Library

Referring to the Repeating Web Client sketch example provided with the Arduino IDE 1.0.1

I've made this work using a static IP address and DNS Server, as in the example sketch.

Is it possible to use DHCP to get a DYNAMIC IP address, while still using a DNS server to resolve a web address ?

The synatax is Ethernet.begin(mac, ip, myDns) for static IP with DNS funtionality.
Just plain Ethernet.begin(mac) for dynamic IP with NO DNS functionality.
I tried Ethernet.begin(mac, , myDNS), but that didn't work.

What I'm trying to do is to get a DYNAMIC IP address yet retain DNS funtionality.

Thank you for helping me.

Bob W


Feb 07, 2013, 04:40 pm Last Edit: Feb 07, 2013, 04:48 pm by SurferTim Reason: 1
Yes. I use it. Call the Ethernet.begin(mac) function. The dhcp server will issue the dns server.

edit: If you want to see what was issued, add this after the Ethernet.begin(mac) call.

Code: [Select]
Serial.print("ip = ");
Serial.print("subnet mask = ");
Serial.print("gateway = ");
Serial.print("dns = ");


Yes. I use it. Call the Ethernet.begin(mac) function. The dhcp server will issue the dns server.


Thank you so much!
That was shockingly easy !
Works great !

How did you know this ?
It was hiding in plain sight.
I never thought to try it.

Bob W


Hi Bob. Every time a new IDE version is released, I dig through the ethernet library to see what they have added. Just a bit of "code mining".  :D

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131