1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-17 06:52:18 +01:00

Ethernet use DNS in examples

Set the DNS-Server as third parameter of Ethernet.begin if at least gateway is specified. Reference is Updated before.

In BarometricPressureWebServer gateway and subnet wasn't used.

Signed-off-by: Eddy <est.git@online.de>
This commit is contained in:
Eddy 2015-08-25 21:47:31 +02:00 committed by Cristian Maglie
parent 3bd810deb8
commit 8a4fd0e6a2
4 changed files with 6 additions and 5 deletions

View File

@ -30,6 +30,7 @@ byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);
IPAddress myDns(192, 168, 1, 1);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
@ -41,7 +42,7 @@ EthernetClient clients[4];
void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
Ethernet.begin(mac, ip, myDns, gateway, subnet);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:

View File

@ -33,8 +33,6 @@ byte mac[] = {
};
// assign an IP address for the controller:
IPAddress ip(192, 168, 1, 20);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
// Initialize the Ethernet server library

View File

@ -27,6 +27,7 @@ byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);
IPAddress myDns(192,168,1, 1);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
@ -37,7 +38,7 @@ boolean alreadyConnected = false; // whether or not the client was connected pre
void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
Ethernet.begin(mac, ip, myDns, gateway, subnet);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:

View File

@ -30,6 +30,7 @@ byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};
IPAddress ip(192, 168, 1, 177);
IPAddress myDns(192,168,1, 1);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
@ -51,7 +52,7 @@ void setup() {
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// initialize the ethernet device not using DHCP:
Ethernet.begin(mac, ip, gateway, subnet);
Ethernet.begin(mac, ip, myDns, gateway, subnet);
}
// print your local IP address:
Serial.print("My IP address: ");