Skip to content

Commit 8a4fd0e

Browse files
eddystcmaglie
authored andcommitted
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 3bd810d commit 8a4fd0e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino

Lines changed: 2 additions & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ byte mac[] = {
3030
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
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

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

0 commit comments

Comments
 (0)