dns lookup only works with DHCP and not with static setup (EtherCard library) When I use DHCP with ether.dhcpSetup() the DNS lookup for NTP ether.dnsLookup("0.pool.ntp.org") works fine, but when I use a static setup (because my Android app needs to know the IP address) with ether.staticSetup(myip); then this returns false and I don't get an IP address from the NTP pool. How come?

I have an Arduino Nano ATmega328 with a ENC28j60 ethernet shield, and therefore use the EtherCard libray.

Full MWE:

#include &lt;EtherCard.h&gt;      // https://github.com/jcw/ethercard
#include &lt;Time.h&gt;           // http://www.arduino.cc/playground/Code/Time

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = {192, 168, 2, 106};
const char poolNTP[] PROGMEM = "0.pool.ntp.org"; //pool to get time server from
uint8_t ntpMyPort = 123; //port for the time server, no idea why needed

byte Ethernet::buffer[700];

void setup () {
  Serial.begin(9600);

 //do not forget to add the extra '10' argument because of this ethernet shield
  if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0) {
    Serial.println(F("Failed to access Ethernet controller"));
  }

  //static setup
  ether.staticSetup(myip);
  ether.printIp("Address: http://", ether.myip);

 //this works
//  if (!ether.dhcpSetup())
//    Serial.println(F("DHCP failed"));

  //Find ip address of a time server from the pool
  if (!ether.dnsLookup(poolNTP)) {
    Serial.println("DNS failed"); //with static setup this line is executed, not so with DHCP
  }
  ether.printIp("Lookup IP   : ", ether.hisip);
}

void loop () {}
DHCP does more than just give you your IP address: it also gives you the Net Mask, the Gateway IP address, and the DNS Server IP address. If you don't call dhcpSetup(), you'll have to do it yourself.

According to the EtherCard documentation, you can do that as follows:

const static uint8_t ip[] = {192,168,0,100}; // Example
const static uint8_t gw[] = {192,168,0,254}; // Example
const static uint8_t dns[] = {192,168,0,1};  // Example

...

if (!ether.staticSetup(ip, gw, dns)
{
    // handle failure to configure static IP address
    // (current implementation always returns true!)
}