DhcpAddressPrinter error

Hello guys, I try the code DhcpAddressPrinter in my Arduino Ethernet Shield. I get the error message in the serial monitor which is Failed to configure Ethernet using DHCP.

I connect my Ethernet shield to my Laptop Acer travelmate ( OS window 7) ethernet port using a Straight through cable. My laptop is connected to a wireless connection or via wifi. I shared the internet connection to the ethernet port by enabling my ICS (internet connection sharing). When I upload the DhcpAddressPrinter sample program I get the error stated above.

What do u think is the problem

/*
  DHCP-based IP printer
 
 This sketch uses the DHCP extensions to the Ethernet library
 to get an IP address via DHCP and print the address obtained.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 12 April 2011
 modified 9 Apr 2012
 by Tom Igoe
 
 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {  
  0x90, 0xA2, 0xDA, 0x0F, 0x0F, 0x97 }; //mac address on the sticker on the shield i use.

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

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:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print("."); 
  }
  Serial.println();
}

void loop() {

}

Have you tried it with the Arduino connected to a router?

SurferTim:
Have you tried it with the Arduino connected to a router?

No, I didn't connect the shield to the router. I'll try it right away.

The reason I suggest that is ICS assigns a specific ip to the ethernet port on the laptop. Last I checked, it was 192.168.0.1/24. If the wireless interface has the same ip network range, that can cause problems.

SurferTim:
The reason I suggest that is ICS assigns a specific ip to the ethernet port on the laptop. Last I checked, it was 192.168.0.1/24. If the wireless interface has the same ip network range, that can cause problems.

I connect the arduino to the router directly and now it show its ip add in the serial monitor.
@SurferTim How can I check the ip add assign to my etherport by the ICS? I want to use the set.up i mention above for the future project I'm making and because its a bit troublesome for me to connect the arduino to the router.

I don't use the ICS features for this, well not directly anyway.

In windows 7 go to your 'network sharing center'
On the left click 'Change adapter settings'

There you will see an icon for your wifi and an icon for your LAN.
Right click the LAN and select bridge connections.
Select both icons and right click -> 'bridge connections'

Once done, your Arduino can use DHCP from the router your laptop connects to.

That bridge connection works. thanks bro..