Ardiuno Outputs a Different IP Address Then One Provided

New to the Ardiuno and just trying to get it and the Shield to accept the IP address I assign to it. For some reason, when I enter the IP address I want to use, upload the sketch and check the serial monitor, the IP address that it outputs is When I do not assign an IP address, it shows the IP address as (using a different sketch to show just the IP address). I am trying to assign the IP address of to it. This IP address is free on my network.

Does anyone have any ideas of what could be causing this? We have the Arduino Uno R3 and the Desloo Ethernet Shield (1280 2560 Duemilanove).

Here is the code that I am using:

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

byte mac[6] = { 0xBA, 0xBE, 0xF2, 0x40, 0x28, 0x9F };
char macstr[18];

void setup() {
  // Random MAC address stored in EEPROM
  if ( == '#') {
    for (int i = 2; i < 6; i++) {
      mac[i] =;
  } else {
    for (int i = 2; i < 6; i++) {
      mac[i] = random(0, 255);
      EEPROM.write(i, mac[i]);
    EEPROM.write(1, '#');
  snprintf(macstr, 18, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

// the dns server ip
IPAddress dnServer(192, 168, 2, 254);
// the router's gateway address:
IPAddress gateway(192, 168, 2, 254);
// the subnet:
IPAddress subnet(255, 255, 255, 0);

//the IP address is dependent on your network
IPAddress ip(192, 168, 2, 181);

// initialize the ethernet device
  Ethernet.begin(macstr, ip, dnServer, gateway, subnet);

  // Start up networking
  Serial.print("    DHCP (");

Serial.print("IP = ");

void loop() {

The output to the above code is:
DHCP (ba:be:f2:40:28:9f)…IP =

Thanks in advance for any help that is provided.

The MAC address is not supplied as a string but as a 6 element byte array. That doesn't hurt as just the first six bytes of the string are used.

My guess is, that you have a hardware problem. In Ethernet.begin() the IP address is written to the WizNet5100 chip and read in Ethernet.localIP(). With correct hardware this should result in the IP address provided. Check the connection of your hardware. Cheap Chinese boards often have ICSP connectors not long enough to connect with the Arduino board. Check with a multimeter if yours have connection.

Figured out what the issue was. I needed to use a different library to get it to work ( <Ethernet2.h> ). We also switched to the Ardiuno Leonardo with chip W5500.