Failed to configure Ethernet using DHCP

J'ai eu du mal à configurer mon shield Ethernet 2. Jai donc décider de tester son fontionement avec les exemples existant.

Voici le croquis:

/*
DHCP Chat Server

A simple server that distributes any incoming messages to all
connected clients. To use telnet to your device's IP address and type.
You can see the client's input in the serial monitor as well.
Using an Arduino Wiznet Ethernet shield.

THis version attempts to get an IP address using DHCP

Circuit:

  • Ethernet shield attached to pins 10, 11, 12, 13

created 21 May 2011
modified 9 Apr 2012
by Tom Igoe
Based on ChatServer example by David A. Mellis

*/

#include <SPI.h>
#include <Ethernet2.h>
#include <SD.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = {
0x90, 0xA2, 0xDA, 0x11, 0x15, 0xF6
};
IPAddress ip(192, 168, 1, 114);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

// telnet defaults to port 23
EthernetServer server(23);
boolean gotAMessage = false; // whether or not you got a message from the client yet

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

// start the Ethernet connection:
Serial.println("Trying to get an IP address using DHCP");
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);
}
// print your local IP address:
Serial.print("My IP address: ");
ip = Ethernet.localIP();
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(ip[thisByte], DEC);
Serial.print(".");
}
Serial.println();
// start listening for clients
server.begin();

}

void loop() {
// wait for a new client:
EthernetClient client = server.available();

// when the client sends the first byte, say hello:
if (client) {
if (!gotAMessage) {
Serial.println("We have a new client");
client.println("Hello, client!");
gotAMessage = true;
}

// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.print(thisChar);
}
}

Le message s'affichant sur le moniteur est le suivant:

Trying to get an IP address using DHCP
Failed to configure Ethernet using DHCP
My IP address: 192.168.1.114.

Je suis chaleureusement dans l'attente d'une réponse. Merci!!

That usually means that the networks DHCP server (in most cases on the internet router) is not serving an IP address for the chosen MAC address.

What can I do to fix this?

ced_rol:
What can I do to fix this?

Read the router's manual. It's probably not any Arduino problem.

I'm using this router.

And with other devices, it easily assign Ip addresses.

Can you access the shield on the IP address you got in the serial monitor?

Is your shield an original Arduino Ethernet Shield 2 or some Chinese clone?

You will see in attache the screenshoot of the serial monitor

and how to do for recognizing if my Ethernet shield is orriginal or a chinese clone?

See my Ethernet shield 2 in attach...

Capture d’écran (7).png

Can you access the shield on the IP address you got in the serial monitor?

You didn't answer that question. Can you ping the shield on the given IP?

It is possible to ping. When I assign a default IP address in IPV4 but on serial monitor is the same . See attach

Excuse me but that configuration is bullshit.

A configuration IP 192.168.137.1, netmask 255.255.255.0 and gateway 192.168.1.1 is wrong because the shield cannot reach the gateway. What was the IP of the PC when you sent the ping? I hope that it was on the same subnet, otherwise Windows 10's network stack is seriously broken.

You should try to setup the Arduino using a configuration that makes sense. If you don't know how to do that, provide all information about your internal network you have to enable us to help you further.

See all information about my internal network in attach...

It seems that the network stack of Windows 10 is seriously broken as it pings an IP address outside its own subnet. I know again why I'm not using this crap.

Change the sketch to use an IP address in your address range (192.168.1.2 - 192.168.1.253).

From the pictures it looks like your accessing the network from the PC by WiFi. Have you tried connecting your PC to the same port (using an Ethernet cable) that you used to connect the Arduino?

If I connect the ethernet cable to the computer, what will the ethernet card be connected to?

I also tried on a computer with Win7 but, it's the same thing. Unless I have to check all the addresses of the range.

I also have the same problem with my Vellman ethernet card. See Attach

If I connect the ethernet cable to the computer, what will the ethernet card be connected to?

Doesn't matter, I want to see if the PC gets an IP address if connected exactly the same way as the Arduino.

I also have the same problem with my Vellman ethernet card. See Attach

That's a good sign for your Ethernet card, it seems the Router is not providing IP addresses to devices connected by cable.

The router has several Ethernet ports. Where did you connect the Arduino?

I connected the computer and the shield to the router like in attach.

But how do you obtaining of ip adress by the computer if the router don't provide it?

But how do you obtaining of ip adress by the computer if the router don't provide it?

Does the computer get an IP on the Ethernet port (no the WiFi!) if you connect it to the router?

pylon:
Does the computer get an IP on the Ethernet port (no the WiFi!) if you connect it to the router?

Yes, my computer get a ip Adress on the ethernet port!

Please post what IP you got. Then disconnect the PC from the Ethernet cable, use this IP in the sketch as the fallback address, compile, load to the Arduino and ping the Arduino on that IP. Post the results.