ethernet sheild and ip

hello all

I have the new arduino ethernet sheild sitting on a mega 2560

Ive never dealt with ethernet before and am having troubles getting it going

i have used the webserver example in the arduino ide as follows

/*
  Web  Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 
 */

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 124,169,102,189 };

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
Server server(80);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");
          }
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}

The ip is from my network (124.169.102.175) and is pinged and confirmed free however im not able to connect

I went through command prompt--ipconfig and it said my ip was 10.1.1.1 ( i assume this is local ip) so
when i input 10.1.1.7 into code i am able to connect to sheild but only from within the network

So my question is am i missing code that allows me to connect to arduino from outside network or would my router be blocking
the connection

any help on this would be greatly appreciated

Cheers
Reece

Hi rholland,
In your code, you have not set the Gateway of the Shield, so it assume that X.X.X.1 is your gateway, if your gateway is not that address, it can be connected in LAN only.
You need to configure the Gateway, and use Ethernet.begin(mac, ip,gateway);
Hope this can help you.

so ive edited the code but still not having any luck

 */

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 124,169,102,189 };
byte gateway[] = {203,212,5,243};

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
Server server(80);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, gateway);
  server.begin();
}

The gateway address i got from my modem and am assuming it is what i needed.

does it need to be changed or do i just put in the same one

Cheers

If you want public access to the shield, it will either need to be on the public network, or the public ip routed through to the private ip (desination NAT) in the router. The router normally does a network address translation (NAT) to your public address. There is a DMZ setting in some residential routers that allow this type of setup.

Behind the router, use the 10.1.1.7 ip. But until you route an ip or port to the private ip, you will have no access from the WAN interface (internet connection), just from your LAN.