How can an Arduino WebServer be viewed outside of my home network ?

Just looking into messing with a webserver via an Ethernet shield

I noticed in some youtube videos that the IP address is basically MY home network address, which is the same/similar to the software etc etc, the only difference seems to be the last number

so thats IPAddress ip(192, 168, 1, xxx);

So my big stupid question is...

If I want to view the page/data coming from my webserver from outside my house (example on another network or even viewing by mobile phone), what do I need to do ?

Do I need webspace ?
Do I have to configure a different number ?
Do I need to use my PC as some kind of gateway ?

I have never really worked with this kind of thing, so treat me gently !! :slight_smile:

The easiest way is to install the Arduino on the public network with a public IP. Otherwise, you will need to port forward your public IP through the router to the private IP of the Arduino.

If you do not have a static public IP, then you would probably need a dynamic dns service like no-ip to track your public IP for you.

Not really a project for the network beginner. Just my opinion.

edit: Insure your web server code is as bulletproof as you can make it. You will come under attack by the outside world. Port scanners can lock up your server if your code is not prepared for it.

Just read some interesting stuff on this topic

@surferTim, thanks for that info.. I shall tread very carefully, thanks for the forewarning :slight_smile:

My new web server code is as bulletproof as they come.

If you put it on the internet and want it tested, PM me with your public IP and I will check it for you. I know a lot of malicious ways to crash the server that are common on the internet. I use the same tests on my server code.

edit: If anyone else wants a public web server test, PM me with the public IP and public port.
FYI, zoomkat's server code will not pass. It will lock up and need to be reset.

Thanks for that Tim, it may be a way off but I will remember that offer, cheers :slight_smile:

Simple arduino server code showing how to embed URL links in the page hrml. The no-ip link may be of interest as it allows the arduino to be accessed from the internet or for the main page to be served from another server.

//zoomkat 04-10-15
//simple button GET with iframe code
//open serial monitor to see what the arduino receives
//use the ' instead of " in html ilnes 
//address will look like when submited
//for use with W5100 based ethernet shields

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

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //ethernet shield mac address
byte ip[] = { 
  192, 168, 1, 102 }; // arduino IP in lan
byte gateway[] = { 
  192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 
  255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString; 


void setup(){

  pinMode(4, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);

  //enable serial data print 
  Serial.println("server test no-ip 04-10-15"); // so I can keep track of what is loaded

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c =;

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 

        //if HTTP request has ended
        if (c == '\n') {

          Serial.println(readString); //print to serial monitor for debuging 

            //now output HTML data header
          if(readString.indexOf('?') >=0) { //don't send new page
            client.println("HTTP/1.1 204 Zoomkat\r\n\r\n");
          else {
            client.println("HTTP/1.1 200 OK"); //send new page
            client.println("Content-Type: text/html");

            client.println("<TITLE>Arduino GET test page</TITLE>");

            client.println("<H1>Zoomkat's simple Arduino button</H1>");
            client.println("Arduino served LAN: <a href='/?on1' target='inlineframe'>ON</a>"); 
            client.println("<a href='/?off' target='inlineframe'>OFF</a>


            client.println("Remote served LAN: <a href='' target='inlineframe'>ON</a>"); 
            client.println("<a href='' target='inlineframe'>OFF</a>


            client.println("Remote served no-ip: <a href='' target='inlineframe'>ON</a>"); 
            client.println("<a href='' target='inlineframe'>OFF</a>"); 

            client.println("<IFRAME name=inlineframe style='display:none'>");          


          //stopping client

          ///////////////////// control arduino pin
          if(readString.indexOf("on1") >0)//checks for on
            digitalWrite(4, HIGH);    // set pin 4 high
            Serial.println("Led On");
          if(readString.indexOf("off") >0)//checks for off
            digitalWrite(4, LOW);    // set pin 4 low
            Serial.println("Led Off");
          //clearing string for next read

Excellent, thanks :slight_smile:

Simple arduino server code showing how to embed URL links in the page hrml. The no-ip link may be of interest as it allows the arduino to be accessed from the internet or for the main page to be served from another server.

That is the server code that won’t make it through my tests. It will lock up and need a reset.

edit: Just to show you I am not just talking, I’ll expose mine to the internet for a while.

Here are the hacks tried so far. They will not crash my server, so forget these. There are no php scripts.
GET /phph/php/ph.php
GET /phpMyAdmin/scripts/setup.php
GET /pma/scripts/setup.php
GET /myadmin/scripts/setup.php

Can't you come up with something better than this? I am hoping to learn something here and improve my code.

edit: The DoS attack didn't work either. It didn't even use all the sockets on my w5100.

FYI, the soccer pic is of the very first AYSO championship team (South Bay Wolverines) just before we whipped Westchester in the Los Angeles Coliseum on 9 Aug 1967 to take that title. I am in the back row second player from the right.

thats a nice simple example Tim, I hope to have something similarly simple for my tests

It only appears simple. The main page loads a css and js file. The waterfall page loads a css file that loads a background image. The soccer page loads a css file and a jpg image.

edit: ...and all load a favicon.ico image.

Ah, ok, not so simple, but actually just what I was looking for as I was thinking about loading JS too, but probably no images as yet

Here are the hacks tried so far. They will not crash my server, so forget these. There are no php scripts.
GET /phph/php/ph.php
GET /phpMyAdmin/scripts/setup.php
GET /pma/scripts/setup.php
GET /myadmin/scripts/setup.php

Trying these again and expecting a different outcome is a sign of a mental disorder.

Hi all

well I tried a few examples and each one got me the same results

I can see my arduino/ethernetShield and get the html from it but ONLY within my LAN

I have tried loads of different things to try and see it as an external user, but I just cant get it to work

I have a BTHomeHub if anyone else has had similar issues

Kinda run out of ideas now

Thanks in advance


You must port forward your public IP to the LAN IP of the Arduino if you want it accessible from the internet. That only works if your ISP is not blocking port 80 requests from the internet. Many ISPs are doing that now.

Otherwise, you must assign a public IP and connect the Arduino to the public interface.

Thanks Tim

I have done this,I assigned the arduino/ethernet to a new HTTP server port (thingy) as set up in my router and put in the LAN address of the arduino.

I started using port 80, then tried 8080, 8081 etc

I had a good read about my hub and how to do this port forwarding

I hadnt created the 'port range' to connect to 'port range'

As soon as I sorted this, it burst into life, I have checked this with a friend and my page is visible

Just need to add the protection now :slight_smile: thanks for your help

@Tim, looking at your code on the playground, it looks very complex, maybe too complex for what I need

all I am trying to do is send a webpage when it is requested, no form, no strange requests from the interrnet

what bit of your code do I need to protect me from incoming nasties ?

It would be nice to have a function that validates incoming requests and reject if bad

can you point me in the right direction please

Regards, Bob

The second server example (old version) on the playground may work for you. It is down at the bottom of this page.
You will need to modify it a little to fit your requirements, but you will need to do that with any example.