Pages: 1 [2]   Go Down
Author Topic: Realworld uses of Arduino as web server  (Read 1602 times)
0 Members and 1 Guest are viewing this topic.
Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 82
Posts: 3863
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do you get the IP address of an incoming?
Logged

The Elders of the Internet know who I am.....

Offline Offline
Full Member
***
Karma: 2
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do you get the IP address of an incoming?
Code:
byte l_rip[] = { 0,0,0,0 };
G_EthernetClient.getRemoteIP(l_rip);
If the first three bytes match your WIFI/Local LAN then the client is logged in locally and you can relax the security.

You can double check that the user is local by extracting the HOST value from the html request. If the HOST value is your external IP address then the user is likely external and has come through your broadband router which has forwarded the html request to your Arduino board.

By recording the IP addresses of failed html requests (e.g. invalid hacker URLs, multiple failed password attempts) you can ban the ip address simply by ignoring it for all future html requests - valid and invalid.

Cheers

Catweazle NZ
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5873
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Ethernet.getRemoteIP() function is not in the standard ethernet library. It requires a library code modification.
http://forum.arduino.cc/index.php/topic,135082.0.html
« Last Edit: January 03, 2014, 05:47:45 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does your entire server reside on the arduino? My ISP provider has some space where I can host a webpage which I have just done.  I had thought that it would  be most efficient to somehow push data  to this webpage, but whatever method you are using seems to work just fine.  Could you explain briefly how you do it, just to get me pointed in the right direction.
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does your entire server reside on the arduino? My ISP provider has some space where I can host a webpage which I have just done.  I had thought that it would  be most efficient to somehow push data  to this webpage, but whatever method you are using seems to work just fine.  Could you explain briefly how you do it, just to get me pointed in the right direction.
Yes - my Ethermega card is the web server. It receives client html requests from the local WIFI LAN and WWW, parses them to determine what is required and then dynamically generates and transmits html pages according to the html (http: URL) request.

I have a fixed external IP address of 219.88.69.69 with my ISP which allows me to access the system from the WWW. I could buy and link a website name but that is not necessary.

My broadband router is a DHCP server and assigns the Ethermega card a fixed IP address based on the mac address that my program code assigns to the Ethermega card. (UDP NTP does not seem to work if you assign the Ethermega's fixed IP address within your program/sketch code.) My broadband modem also uses port forwarding to send external WWW port 80 http traffic (html requests) to the fixed IP address of the Ethermega card.

For the underlying core technologies (ethernet, UDP NTP, email, SD card, etc) I started with Arduino example programs. I studied them carefully and then modified them according to my needs. Other application functionality was built from scratch based on my extensive software development background.

It started my project on 15th August and has about 6,000 lines of code. This will give you some idea of the development effort. There is no brief explanation.

Catweazle NZ


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great. I think I am headed in the right direction.  50 lines done. Only 5950 lines to go.  One  thing I need to check on is whether my webpage has a static IP or not.   Here is the link though there's nothing on it.    http://users.xplornet.com/~gordswebpage .  I'm pretty sure my mega 2560 with the internet shield will function just like your ethermega.   And I currently  have a webserver running locally with a few analog values.  I have not yet forwarded the port on my D-link 615 router mostly because I wasn't sure how.  What I'd like a little guidance on is how to get this server info onto the webpage? 
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great. I think I am headed in the right direction.  50 lines done. Only 5950 lines to go.  One  thing I need to check on is whether my webpage has a static IP or not.   Here is the link though there's nothing on it.    http://users.xplornet.com/~gordswebpage .  I'm pretty sure my mega 2560 with the internet shield will function just like your ethermega.   And I currently  have a webserver running locally with a few analog values.  I have not yet forwarded the port on my D-link 615 router mostly because I wasn't sure how.  What I'd like a little guidance on is how to get this server info onto the webpage? 
You may be confused about my implementation. I am not using any web page provided by my ISP to host any of my system's information. It is my Ethermega card that is the web server and published its own web pages directly when anyone, anywhere in the world types in the http://219.88.69.69/2WG/ URL. My Ethermega card directly generates all the html code to publish its web pages.

You do not need a static IP address from your ISP and you do not need to set up port forwarding from your broadband modem router to your Arduino unit for local development and local web access. On my WIFI LAN I can access my Ethermega web server and its web pages using this URL http://192.168.1.177/2WG/ in a browser on any PC or IOS device - the /2WG/ is not necessary - I just use it as an alternate start page to frustrate web crawlers who normally access root web pages and then crawl your website from there.

192.168.1.177 is the fixed internal IP address assigned by the DHCP functionality of my broadband modem router (based on the MAC address of the Ethermega card passed to the broadband modem router when it connects) - but you can embed your fixed IP address within your Arduino sketch if you do not plan to use UDP NTP at this time to get the time off the internet.

I suspect you know much of the above.

You should be able to determine if your internet connection has a static IP address by logging into your broadband modem router and looking for its external/WAN IP address. If that value never changes (try rebooting the router) then it is likely static. Some ISPs charge a fee for a static IP address - others give them away for free in some circumstances. But you only need to worry about this if you need to access the system externally from the WWW.

Cheers

Catweazle NZ
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I was (and still am) confused.  I now  realize that my ISP webpage is of no use to my arduino webserver.  I know I can view and develop my web pages locally. I've done that.  Mine sits at 168.192.0,177 and I can access it from any local terminal.   I'd like to set up my arduino webserver and router so that they are accessible from the www. I'd also like to protect myself from   webcrawlers, etc.  The server really only needs to be accessible by me when I'm away from home.  My understanding is that connecting to the www is accomplished by port forwarding in the router, however I have not attempted this nor do I really understand it.  Another problem I have is that I am not on a static address. Maybe this is solved with port forwarding... I don't know.  If you could just tell me how you get your data on the internet, I think it would help me to figure out mine.

Edit: Just found a great link at http://www.instructables.com/id/ServDuino-Arduino-Webserver/step1/What-You-Will-Need/
I think this is going to answer most of my questions for now.
Thanks
Gord.




« Last Edit: January 03, 2014, 10:31:57 pm by Pizzanova » Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 82
Posts: 3863
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK Gord, here goes:

Port Forwarding ius the opening up to the outside world, of a port on "your" side, the lan. The Arduino code EthernetServer server(8085); puts the server (in my case) on port 8085, and that port needs to be made visible; port forwarding does that.

Without forwarding, your server will never be seen from outside. How you do the forwarding, depends on the hardware of the router. Turns out mine, for example, has a menu item when I access the router from the lan side thru a browser. You'll need to check your user docs for that. Or Google port forward and your router model.

My ISP wouldn't let me forward port 80, the default for a server, so I buggered around until 8085 worked. Go to portforward and download their port checker- it'll tell you if a particular port is accessible from outside, ie has been forwarded properly.

Next, on the static address. You don't have to have a static address. You can use dynamic dns, and there are a number of purveyors of that such as dyn. What that is is that you get a domain name from them, and that name stays attached to the ever-changing ip address. How does it know it's changed? Two ways:

  • First, you download their desktop widget thing to one of your network pcs. That app keeps an eye on the wan ip, and if it changes, like on a router reset, it informs dyn. Within a minute or so of the reset and new ip, the name is matched to the new number
  • Second, your router may support dynamic dns. Check the docs again. On mine, there's a config item to let me tell the router about dyn. In fact dyn was in a pre-loaded list in my router config. So now, every time the router changes its ip address, it immediately lets dyn know and my domain name is up to date

EDIT: Just noticed my router docs use the term Virtual Server for Port Forwarding.
« Last Edit: January 04, 2014, 01:56:09 am by JimboZA » Logged

The Elders of the Internet know who I am.....

Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got it Now.  And of course now it seems pretty straight forward and I wonder how I was having so much trouble with this.  It was that whole other website that I was trying to fit in that  got me confused.  Thanks for spoon feeding me.  I only hope that eventually I will be able to help someone here too.

Gord.
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 82
Posts: 3863
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're welcome. I was the spoon-feedee a few weeks ago on this....
Logged

The Elders of the Internet know who I am.....

Pages: 1 [2]   Go Up
Jump to: