Skip to content

Examples: Add DNS to Ethernet.begin #3728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion libraries/Ethernet/examples/ChatServer/ChatServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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: ");
Expand Down