Making webpy framework accessible from outside the local network


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Making webpy framework accessible from outside the local network
# 1  
Old 12-14-2013
Making webpy framework accessible from outside the local network

I am using ubuntu 12.04.03. I have some basic experience with webpy and I had it working for my LAN just by following the tutorial. The framework needs to be able to be used from outside the local network. I have difficulty seeing how to make the framework accessible from outside the lan. I tried opening a specific port (with "# iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 8081 -j ACCEPT" then I check: "# netstat -ln | grep 8081 and I get: tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN" ) and use "python web_py_test.py MY_IP:8081" without success.

If I understand it at all, we can have a computer connected on a wifi with a non-static IP and there is a way to launch our webpy framework which can be accessible from the outside world. I am experimenting with the hello script:

Code:
import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:
    def GET(self, name):
        if not name:
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()
~

I observe that nothing is declared in the script about IPs or ports.

Last edited by frad; 12-14-2013 at 11:04 AM.. Reason: browser crashed
# 2  
Old 12-14-2013
How exactly is your "local network" connected with the "outside network"? Do you have NAT in between? If so, it will be a little more effort than just to unguard a port.

Tell us about your environment and we can help you find out a solution.

I hope this helps.

bakunin
# 3  
Old 12-14-2013
There is no outside network. I just have wifi and ethernet and the ips are dynamic. I did not configure any NAT. What I want to do is to arrive to the result that everyone (with his own computer, with his own internet connection) will be able to type a specific ip and port on his webrowser and see my webpy framework. The user should be able to enter some variables and launch a calculation (as I am doing locally) that will run on my computer.
# 4  
Old 12-15-2013
I think i should mention that i do not know this "webpy framework", but i am pretty seasoned in networking. So, please bear with me when my questions are sometimes asking the (for you) obvious.

Quote:
Originally Posted by frad
There is no outside network.
As it is, i don't think so. To quote you:

Quote:
Originally Posted by frad
The framework needs to be able to be used from outside the local network.
If this is not an "outside network", what else is it? How is it connected to your "local network"? (I suspect this is the Wifi-box you mentioned, but just to be sure. And do you have routing enabled on this box or does it act as a switch?)

Quote:
Originally Posted by frad
What I want to do is to arrive to the result that everyone (with his own computer, with his own internet connection) will be able to type a specific ip and port on his webrowser and see my webpy framework. The user should be able to enter some variables and launch a calculation (as I am doing locally) that will run on my computer.
OK. First question: with "everyone" you mean "anybody on the internet" (like, for instance, me) or "anyone connected to the box i spoke above" (the Wifi-LAN connection)?

Second question, as i do not know webpy: does one need a browser (or any other software like a terminal emulation, ....) to do so or does it have its own protocol and client/server applications?

I hope this helps.

bakunin
# 5  
Old 12-15-2013
Your questions are helpful. I am only connected to the modem/router and the ips are dynamic and yes I wish that everyone on the internet would be able to type an ip/port and see the framework.

It will take you one minute to see what webpy does here: http://webpy.org/docs/0.3/tutorial

All computers connected via wifi/ethernet to my modem/router can see the framework by typing http://0.0.0.0:8080/ or variants after I start the server with
Code:
 python code.py

I hope we are advancing
# 6  
Old 12-15-2013
Quote:
Originally Posted by frad
All computers connected via wifi/ethernet to my modem/router can see the framework by typing http://0.0.0.0:8080/ or variants after I start the server with
Code:
 python code.py

OK, things start to get clearer. I understand that basically your framework is a sort of web server module. I presume it is configured correctly in its own right, because otherwise you would not be able to use it from your local network.

Next question: what are the IP-networks you use? Look at your IP-addresses and subnet masks. If the addresses are one of these:

Code:
10.x.x.x
172.[16-31].x.x
192.168.[0-255].x

you use indeed NAT and we have to sort that out first (in fact most consumer Wifi-routers do that per default). As you say you use dynamic IP addresses chances are you do not have a range of official IP addresses (who still, these days?) but merely a so-called "private address space"-network, as defined in RFC 1597. In this case, to make your server known, you will have to use dynamic DNS to keep at least the name the service is reachable at constant.

A final remark:

Quote:
If this really works you'd better never succeed in connecting the system to the internet. The network address "0.0.0.0" is the "joker for all" and if the whole world comes down on your system requesting its services chances are it won't keep up with the load.

I still would appreciate if you could give a little more information aforehand instead of letting me guess. You now said several times that your IP addresses are dynamic but were silent about your network layout (which networks, subnet masks, connected how?) save for what i explicitly asked. As your problem is most probably a firewall problem it might help a wee bit to know these things.

I hope this helps.

bakunin
# 7  
Old 12-15-2013
The result of
Code:
ifconfig

is -I added some stars-:

Quote:
eth0 Link encap:Ethernet HWaddr dc:0e:a1:ba:82:1c
inet addr:192.168.178.** Bcast:192.168.178.*** Mask:255.255.255.0
inet6 addr: fe80::de0e:a1ff:feba:821c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17451 errors:0 dropped:0 overruns:0 frame:0
TX packets:12786 errors:0 dropped:0 overruns:0 carrier:3
collisions:0 txqueuelen:1000
RX bytes:10460410 (10.4 MB) TX bytes:2232289 (2.2 MB)
Interrupt:44

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:73323 errors:0 dropped:0 overruns:0 frame:0
TX packets:73323 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7336237 (7.3 MB) TX bytes:7336237 (7.3 MB)

wlan0 Link encap:Ethernet HWaddr 44:6d:57:a1:e2:7b
inet addr:192.168.178.** Bcast:192.168.178.255 Mask:255.255.255.0
inet6 addr: fe80::466d:57ff:fea1:e27b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1811250 errors:0 dropped:0 overruns:0 frame:0
TX packets:1227810 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1894687899 (1.8 GB) TX bytes:172295424 (172.2 MB)
I confirm that
Code:
python web_py_test.py IP:8080

allows the framework to be accessed from any computer connected to my modem/router

Code:
python web_py_test.py 8081

results in that the framework is accessible only from the computer that launched it

Code:
python web_py_test.py

does not work at all:

Code:
http://0.0.0.0:8080/
Traceback (most recent call last):
  File "web_py_test.py", line 15, in <module>
    app.run()
  File "/home/frad/.../application.py", line 313, in run
    return wsgi.runwsgi(self.wsgifunc(*middleware))
  File "/home/.../wsgi.py", line 54, in runwsgi
    return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
  File "/home/.../httpserver.py", line 157, in runsimple
    server.start()
  File "/home/.../wsgiserver/__init__.py", line 1753, in start
    raise socket.error(msg)
socket.error: No socket could be created

---------- Post updated at 10:23 AM ---------- Previous update was at 10:15 AM ----------

Also:

Code:
sudo iptables -t nat -L
 
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination

---------- Post updated at 10:42 AM ---------- Previous update was at 10:23 AM ----------

In addition the result from the web site whatismyip

is a completely different ip

Last edited by frad; 12-15-2013 at 11:43 AM.. Reason: typo
 
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Infrastructure Monitoring

SF4800 SC not accessible thru network

Hi All, I have my SC setup as attached below but I am having problem accessing the port thru network. sc0 was accessible only after i failed over the configuratios to sc1 (now then sc1 was not pingable :(). Just wondering is there anything wrong with my sc settings? Appreciate your advice. ... (4 Replies)
Discussion started by: honmin
4 Replies

2. IP Networking

ssh server is attachable from local network not from another network

hello i have a ubuntu ssh server that i can acess from any of my comnputers but only if they are on the same wireless network as the server. i tested trhis my tehtehring my samsung blackjack to my windows partition and installing openssh to windows it works when windows is on the wireless but no... (1 Reply)
Discussion started by: old noob
1 Replies
Login or Register to Ask a Question