Problems connecting to a server running on a (sometimes virtualized) Windows machine - python

***Sorry for using the Term Host & Guest I see that has confused things slightly. By Host I mean Client which listens on your desired port for incoming connections and by Guest I mean Server which attempts to retrieve the IP of your pre-defined Dyndns.org address. Then tries a connection. You may say that's 'backwards' but for my applications scenario that's the fitting method. Since I'm in the United Kingdom my public IP I mentioned starts with 91.
Here's two diagrams to explain if the Server connections to the Client running on the same OS.
Ubuntu - Linux
Connection over 127.0.0.1 = SUCCESS!
Connection over public IP = SUCCESS!
Windows - Laptop TinyXP - Laptop Vista - VM TInyXP
Connection over 127.0.0.1 = SUCCESS!
Connection over public IP = FAILED!
So the problem is Windows. I've tried the Twisted examples and again they work over local host but not via public IP on Windows so it can't be my script. It can't be the firewall as the two TinyXP installations don't have the default firewall, whilst the Vista laptop did have the default shipped one however I unblocked the process after it popped up prompting me. and thus did not yield any better results.
To forward the port I went to my Orange Livebox's configuration page (192.168.1.1) and forwarded the TCP port 4005. Just as I did for when I tested it on Ubuntu (Instead using the 4004 port) so it can't be that either. I attempted to use wireshark (Found it hard to understand). I started capturing packets on all ports, then fired up the Client followed by the Server. Resulting entries are here http://pastebin.com/ddytpydz
Alas I have no more ideas on what I can do. The twisted version I'm using is one of the latest whilst the Python version is 2.6 Any one have some ideas?

So maybe there is some windows limitations for listenings pors. As far as I remeber some Windows can have max 5 ports open for listening. But I don't remeber exacly.

Sounds like a firewall problem. I would add either the port or python.exe to the approved list.
Are any of the Windows machines joined to a domain?

Related

Flask-SocketIO server hosted on Windows 10 works on all ports except port 80 when outside local network

I am trying to host a flask-socketio server on a Windows computer (currently only for the purpose of learning, it will later be moved to a Raspberry Pi) and am rather new to flask. Everything has gone smoothly until trying to access the server from outside of my local network.
The server is being run with the following code, as many other StackOverflow posts have explained is necessary:
if __name__ == '__main__':
socketio.run(app, debug=False, host='0.0.0.0', port=80)
I have port forwarded correctly and the server is visible within my own network (on all ports) via either my global ip, local (192.168.X.X) address, or localhost. It is also visible to external users if the server is hosted on anything other than port 80, including the flask default of 5000. However, if I host on port 80, nothing is visible externally.
I have experimented extensively with the windows firewall inbound rules for both port 80 and the python executable. The only cause I haven't been able to rule out revolves around something specific to Windows 10 blocking inbound port 80 connections. There are no other competing servers running on the machine and no errors thrown by python/Flask-SocketIO in any setup/connection mentioned here.
Questions:
Are there any gotcha's I simply haven't been able to find regarding either Flask-SocketIO or the Windows system? What other parts of the "chain" should I look into to diagnose this?
As the comments on the original question suggested, this situation is indicative of ISP's blocking the ports used, especially in the case where other port numbers below 1000 work (otherwise, this would hint to a firewall issue somewhere).
After some long calls with my ISP, I've discovered that port 80 and 25 are, indeed, blocked.

SimpleHTTPServer: other devices can't connect to the server

Lately I've been playing with Python to discover its potential and I've just stumbled upon SimpleHTTPServer.
I'm on Windows 10.
I run:
python -m SimpleHTTPServer
the output is:
Serving HTTP on 0.0.0.0 port 8000 ...
I've opened the browser both on smartphone and tablet, but none of them can connect to the server when I type "http://127.0.0.1:8000".
(Translating from italian, maybe is not the exact translation)
iPad: "Safari can't open the page because the server has stopped responding"
Android: "WebPage does not respond. the webpage may be temporarily not available or it could have been moved to another address"
Why does it not work? How do I fix this?
Maybe your firewall is blocking access to python based server
Try this:
Open windows firewall
click on "allow an app or feature..." on the left side of the opened window
search for python in the list and check both the boxes private and public
It should work now
127.0.0.1 is always the IP address of the local system (its associated hostname is "localhost"). In other words, if you type 127.0.0.1:8000 on your tablet or Android device, the browser on that device will try to connect to a server running on the same device, listening on port 8000. You'll need to find out the IP address of the computer you're running Python on, and type that instead. You can use the ifconfig command on Unix, or ipconfig on Windows.

Send a string from windows to vmware-ubuntu over socket using python

I am trying to send a string from the windows to the linux vmware on the same machine.
I did the following:
- opened a socket on 127.0.0.1 port 50000 on the linux machine and reading the socket in a while loop. My programming language is python 2.7
- send a command using nc ( netcat ) on 127.0.0.1 port 50000 from the windows machine ( using cygwin ).
However, I dont receive any command on the linux machine although the command sent through windows /cygwin is successful.
I am using NAT ( sharing the hosts IP address ) on the VMWARE Machine.
Where could be the problem?
When you use NAT, the host machine has no way to directly contact the client machine. All you can do is usign port forwarding to tell vmware that all traffic directed to the designated ports on the host is to be delivered to the client. It is intended to install a server on the client machine that can be accessed from outside the host machine.
If you want to test network operation between the host and the client, you should configure a host-only adapter on the client machine. It is a virtual network between the host and the client(s) machine(s) (more than one client can share same host-only network, of course with different addresses)
I generally configure 2 network adapters on my client machines :
one NAT to give the client machine an access to the open world
on host-only to have a private network between host and clients and allow them to communicate with any protocol on any port
You can also use a bridged interface on the client. In this mode, the client machine has an address on same network than the external network of the host : it combines both previous modes
Your problem is multi-fold
1st
setup Ubuntu-VM's IP-network & a static IP-address of this guest O/S.
VALIDATE:
$> ifconfig // list all setup Ubuntu interfaces/addresses
2nd
if your VM guest is hosted as being connected to a different IP-network, than your Windows system, make sure there is a connectivity and route between these two hosts ( VMnet configurator in VmWare will help a lot to solve this ).
VALIDATE:
C:\ ping <aUbuntuVmIpADDRESS> // prove an online visibility Win->UbuntuVM
3rd
make sure your Windows O/S permits the use your selected TCP-port#
VALIDATE:
list all allowed / add if-needed TCP-port# in Windows Firewall setup
4th
make sure your python sends all socket-traffic not to a Windows local loopback interface <127.0.0.1>, but towards the visible IP-address of the Ubuntu-VM guest O/S, ( setup as per step-1, verified as per step-2 ) using an unused, permitted TCP-port# ( verified/setup as per step-3 )

Can't see page in local lan

I try to setup a simple webinterface with cherrypy & python.
The page is visible over localhost:8080. If I try a different computer on the same LAN and try to connect with it via 192.168.1.100:8080 it doesn't work however. Do I need to open some ports? I thought this would not be needed with linux.
OS: Ubuntu on both systems
Tried Browsers Chrome & midori
Make sure to bind your server to 0.0.0.0:8080 instead of localhost:8080.
localhost always resolves to the loopback interface, which is only reachable from the same host.
0.0.0.0 on the other hand means "all interfaces" (also known as INADDR_ANY).
For details read up about INADDR_LOOPBACK and INADDR_ANY in the ip(7) manpage.

How do I setup a python, telnet proxy for a device on a different network over SSH?

Overview:
I have a device sitting on a local network to a computer that is sitting on an outside network. I would like to create a software program that allows me to seamlessly connect to the device from a computer on a different network. For purposes of this question, I've created a picture to help describe the network flow. What I need help with is what python packages I would need to develop the solution for this problem.
Details:
I have a computer MYPC (IP address 192.168.0.168) that is attached to the internet running through a proxy server (ROUTER1). I have full control over MYPC's environment, which is running Linux.
I have a second computer SOMESERVER (IP address 192.168.1.168) that is attached to the internet running through a proxy server (ROUTER2). In addition, SOMESERVER (IP address 10.0.0.159) is also attached to a local network (LOCAL). SOMESERVER is running windows. I have very limited control with SOMESERVER: I am able to send an executable to SOMESERVER that can run once before it is removed. I do not know the internet/world IP address of the ROUTER2 initially.
I have a device (DEVICE1) attached to SOMESERVER through LOCAL (IP address: 10.0.0.157).
I have another device (DEVICE2) attached to SOMESERVER through LOCAL (IP address: 10.0.0.158). DEVICE(x) runs linux. I have python on DEVICE(x) and I could install a pure python package if I needed to. However, I do not have the ability to compile for DEVICE(x).
I can connect between SOMESERVER and MYPC through the internet using SSH over ROUTER1 and ROUTER2. I can connect between SOMESERVER and DEVICE1 through the local network (LOCAL) using Telnet. I can connect between SOMESERVER and DEVICE2 through the local network (LOCAL) using Telnet.
I want to send a program to SOMESERVER that allows me seamless access over SSH and Telnet to DEVICE1 and DEVICE2 from MYPC. In addition, I want that program to be running python.
Here's a picture that helps explain the above problem:
Solution:
What I think I want is as follows. I need help with the details and what packages I might need to make it happen.
Part 1: The Dial Home Client and Server
Create a "dial home" server program (DIAL_HOME_SERVER) for MYPC which listens for any one dialing home and then will "dial into" any SOMESERVER that "dials home" using SSH.
Create a "dial home" client program (DIAL_HOME_CLIENT) for SOMESERVER which is downloaded as part of a package
Part 2: The Proxy Server
Create a ssh to telnet proxy server program (PROXY_SERVER) for SOMESERVER which listens for connections from MYPC and funnels them into a telnet connection to DEVICE(x).
Thanks to Greg Hewgill, it sounds like I can use Paramiko to pull together the PROXY_SERVER code on SOMESERVER. It appears that Paramiko also requires PyCryto, and the Windows binary for it can be found here.
Future Robustness
At a future date, the telnet connection will be replaced with an SSH client (dropbox on DEVICE(x)).
In Closing
I think the above will allow MYPC to connect "seamlessly", but the details of how to put together these programs is unknown to me. I already know how to package up a python program using Innosetup and/or py2exe. What I'd love to see is links pointing to different pieces of the solution so I can pull it all together. And then I can post it.
Thanks in advance!
I have to admit that I didn't quite follow all of your description, especially the "dial home" client/server part. However, your diagram seems sufficient for understanding.
Set up port forwarding on "router2" that forwards the incoming SSH port to your Windows server.
Write a Python program (you will probably find paramiko helpful) that runs on your Windows server, listens for SSH connections, and opens a telnet connection to one of your devices on the back end.
That seems sufficient to me. If you've got weird restrictions on the Windows server about only being able to run an executable once before it is deleted, that seems like another problem to solve that doesn't really relate to this tunnelling problem.

Categories