Pages: [1]   Go Down
Author Topic: DHCP *AND* DNS with Ethernet Shield Library  (Read 943 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 146
Posts: 6027
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Serial.print("ip = ");
Serial.println(Ethernet.localIP());
Serial.print("subnet mask = ");
Serial.println(Ethernet.subnetMask());
Serial.print("gateway = ");
Serial.println(Ethernet.gatewayIP());
Serial.print("dns = ");
Serial.println(Ethernet.dnsServerIP());
« Last Edit: February 07, 2013, 10:48:33 am by SurferTim » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Tim:

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

Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 146
Posts: 6027
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".  smiley-grin
Logged

Pages: [1]   Go Up
Jump to: