Go Down

Topic: Setting up Arduino Webserver for remote access (Read 56487 times) previous topic - next topic

ofey

I have noticed that unless the Arduino code is set to port 80 nothing works (locally). So I am forwarding to port 80 and so on my router I must have a start port which is less, say 62 and an end port of 80. Why can't I just have 80 as the start and end port?

Thanks,

Shane

gr0p3r

Shane,
What model and make is your router. I'll get the manual and be able to help more. In most cases, the start and end port should be the same. It's for forwarding a range of ports. You can forward 80 to 80, the reason you wouldn't is that when post scanners scour the Internet they usually only an the first few thousand ports, so I'd you pick a high number you are more likely to be passed by by potential hackers. 80 can be fairly insecure. But depends if that's an issue for you.
Your modem interface, does it say port forwarding or virtual server or Nat?
It should go something like this:
Start port: 64000(whatever) end port: 64000(same) ip: 192.168.1.254(arduino ip) start port: 80 end port: 80
Or not have the end port options. But as I said, get me make n model n I can e more specific.

PeterH


I have noticed that unless the Arduino code is set to port 80 nothing works (locally).


What do you mean by that? I'd suspect you have a firewall somewhere that is allowing the HTTP but blocking other ports by default. But without more details about the symptoms, it's hard to guess.

ofey

#18
Aug 09, 2012, 01:41 pm Last Edit: Aug 09, 2012, 01:47 pm by ofey Reason: 1
Hi,

My router is a Zylex and the model number is P-660HW-T1 v3 The manual is here. I've also attached a screen shot of the port forwarding setup page on the router.

I am now setting the start and end port to 80.

When I said that nothing works locally i mean that in the arduino code unless the port is set to 80 I cannot even upload my sketch.

Code: [Select]
EthernetServer server(80); //server port

Thanks,

Shane

gr0p3r


ofey

I got it working. It took a few days but this is brilliant now I could control any circuit over the internet.

Thanks for all your help.

I will next write the settings out and where to get each from for anyone else who got stuck on this. Basically what I was looking for when i started.

Thanks again,

Shane

ofey

#21
Aug 09, 2012, 07:20 pm Last Edit: Aug 10, 2012, 12:42 am by ofey Reason: 1
Code: [Select]
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xFB, 0x94 }; //this is the mac address on the sticker on your Ethernet shield
byte ip[] = { 192, 168, 1, 177 }; //here you are setting the ip address of the Ethernet shield yourself. The last three digits can be whatever you like. But they must be inside the pool of allowed ip's which is usually 200. So you can use any number from 192.168.1.1 to 192. 168.1.200 as long as they are not being used my any other device on you network. Use this ip when setting up port forwarding in the router for NAT-> port forwarding.
byte gateway[] = { 192, 168, 1, 1 }; //this is the ip you get when you run the example sketch DhcpAddressPrinter to find this ip remember to look at the serial monitor.
byte subnet[] = { 255, 255, 255, 0 }; //this can be found in cmd->ipconfig, but usually it is as it is here and so shouldn't need to be changed.
EthernetServer server(80); //you will have to set this to the same as the start and end ports of the router configuration. Both the start and end ports are the same.


In the router's configuration for port forwarding under NAT the start and end ports are both 80 and the ip there is 192.168.1.177 same as the line ip[].

You can't test this from inside your own network. You need to be outside and there just type your router's external ip immediately followed by (with no space) a colon and the port you chose. For example 89.42.23.11:80 (not my real ip!) Your router's external ip can easily be found by typing into Google "what is my ip".

Also you will need to lower your firewall to get this to work definitely on your router and probably also on your anti-virus software.

zoomkat

Quote
Your router's external ip can easily be found by typing into Google "what is my ip".


You can usually also look at the WAN IP address your router is using.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

ofey

#23
Aug 10, 2012, 12:22 am Last Edit: Aug 10, 2012, 12:26 am by ofey Reason: 1
I use Google to get the ip and paste it into my browser to get in to my router. I don't know any other way.

How do you get in to your router?

Thanks,

zoomkat

Quote
How do you get in to your router?


You read your router's user manual. I have a $40 netgear router from walmart and I just type in 192.168.1.1 in my browser and open the router user interface page.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

ofey


PeterH

The address isn't always 192.168.1.1. It will almost always be 192.168.1.x indicating that it's a private network, but the x can vary depending on the router. For example mine is 192.169.1.254.

If your PC is using the router to access the internet then the router will be the default gateway for your PC. You can run ipconfig on the PC to show the default gateway address. Or read the manual for the router, if you have it.

ofey

I understand now and 192.168.1.254 works for me.

Thanks,

Shane

zoomkat

Quote
The address isn't always 192.168.1.1. It will almost always be 192.168.1.x indicating that it's a private network, but the x can vary depending on the router. For example mine is 192.169.1.254.


Some routers also use 192.168.0.x as the base lan IP address.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

gr0p3r

Im not sure what happened to my last post, but i had a lot more info than just you manual is crap :S
sorry bout that, but looks like you have it all sorted anyway so thats good.

Go Up