I'm trying to build a little project using the Arduino Ethernet library, but I'm having a weird DNS issue:
It cannot resolve any domain name that is local to my network, but it has no problem resolving public domain names.
No other system on my network has problems with these local domain names. It just seems to be the Arduino.
Here's what I'm using:
- Arduino Uno R3
- Arduino Ethernet Shield R3
- Arduino IDE 1.0.3
- Asus RT-N66U Router (provides the DNS server)
Here's my test sketch:
#include <SPI.h>
#include <Ethernet.h>
#include <Dns.h>
#include <EthernetUdp.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
EthernetClient client;
void setup() {
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while(true);
}
delay(1000);
Serial.println("connecting...");
DNSClient dnsClient;
// Router IP address
byte dnsIp[] = {192, 168, 11, 1};
dnsClient.begin(dnsIp);
// Regular DNS names work...
IPAddress ip1;
dnsClient.getHostByName("www.google.com", ip1);
Serial.print("www.google.com: ");
Serial.println(ip1);
// However local ones defined by my router do not (but they work fine everywhere else)...
IPAddress ip2;
dnsClient.getHostByName("Tycho.localnet", ip2);
Serial.print("Tycho.localnet: ");
Serial.println(ip2);
}
void loop() {
}
Here's its output (the second IP address is incorrect):
connecting...
www.google.com: 74.125.227.84
Tycho.localnet: 195.158.0.0
Here's the correct information given from a Linux machine connected to the same network:
$ nslookup www.google.com
Server: 192.168.11.1
Address: 192.168.11.1#53
Non-authoritative answer:
Name: www.google.com
Address: 74.125.227.80
Name: www.google.com
Address: 74.125.227.84
Name: www.google.com
Address: 74.125.227.82
Name: www.google.com
Address: 74.125.227.83
Name: www.google.com
Address: 74.125.227.81
$ nslookup Tycho.localnet
Server: 192.168.11.1
Address: 192.168.11.1#53
Name: Tycho.localnet
Address: 192.168.11.2
What's going on?