Skip to content

Commit 1609fbc

Browse files
committed
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>
1 parent d9bb896 commit 1609fbc

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ byte mac[] = {
3030
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
3131
};
3232
IPAddress ip(192, 168, 1, 177);
33+
IPAddress myDns(192, 168, 1, 1);
3334
IPAddress gateway(192, 168, 1, 1);
3435
IPAddress subnet(255, 255, 0, 0);
3536

@@ -41,7 +42,7 @@ EthernetClient clients[4];
4142

4243
void setup() {
4344
// initialize the ethernet device
44-
Ethernet.begin(mac, ip, gateway, subnet);
45+
Ethernet.begin(mac, ip, myDns, gateway, subnet);
4546
// start listening for clients
4647
server.begin();
4748
// Open serial communications and wait for port to open:

libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ byte mac[] = {
3333
};
3434
// assign an IP address for the controller:
3535
IPAddress ip(192, 168, 1, 20);
36-
IPAddress gateway(192, 168, 1, 1);
37-
IPAddress subnet(255, 255, 255, 0);
3836

3937

4038
// Initialize the Ethernet server library

libraries/Ethernet/examples/ChatServer/ChatServer.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ byte mac[] = {
2727
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
2828
};
2929
IPAddress ip(192, 168, 1, 177);
30+
IPAddress myDns(192,168,1, 1);
3031
IPAddress gateway(192, 168, 1, 1);
3132
IPAddress subnet(255, 255, 0, 0);
3233

@@ -37,7 +38,7 @@ boolean alreadyConnected = false; // whether or not the client was connected pre
3738

3839
void setup() {
3940
// initialize the ethernet device
40-
Ethernet.begin(mac, ip, gateway, subnet);
41+
Ethernet.begin(mac, ip, myDns, gateway, subnet);
4142
// start listening for clients
4243
server.begin();
4344
// Open serial communications and wait for port to open:

libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ byte mac[] = {
2828
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
2929
};
3030
IPAddress ip(192, 168, 1, 177);
31+
IPAddress myDns(192,168,1, 1);
3132
IPAddress gateway(192, 168, 1, 1);
3233
IPAddress subnet(255, 255, 0, 0);
3334

@@ -49,7 +50,7 @@ void setup() {
4950
if (Ethernet.begin(mac) == 0) {
5051
Serial.println("Failed to configure Ethernet using DHCP");
5152
// initialize the ethernet device not using DHCP:
52-
Ethernet.begin(mac, ip, gateway, subnet);
53+
Ethernet.begin(mac, ip, myDns, gateway, subnet);
5354
}
5455
// print your local IP address:
5556
Serial.print("My IP address: ");

0 commit comments

Comments
 (0)