Change DNS server without using Static IP address

Re Ethernet Library:

I am able to change the DNS server to one of my choosing if I set up a Static IP address. Thus: Ethernet.begin(myMACaddress, myStaticIPaddress, myDnsServer);

Is it possible to do this with a Dynamic IP address - provided by DHCP ?

I tried Ethernet.begin(myMACaddress, (left empty) , myDNSserver) but this did not work.

Thank you.

I don't think you can unless you modify the ethernet library. Are you willing to do that? I have the code additions to do it. It isn't hard to do. Just a few lines of code.

Add this line to Ethernet.h after the dnsServerIP prototype.

  IPAddress dnsServerIP();
// add this line
  void setDnsServerIP(IPAddress remote_ip);

Add these lines to Ethernet.cpp after the dnsServerIP function.

IPAddress EthernetClass::dnsServerIP()
  return _dnsServerAddress;

// add these lines
void EthernetClass::setDnsServerIP(IPAddress remote_ip)
  _dnsServerAddress = remote_ip._address;

Then use it like this after the Ethernet.begin call:

  IPAddress newDns(8,8,8,8); // Google's dns server ip