Virtual Network using Vmware - python

I have a vmware workstation pro 12 and I can open multiple virtual machines at a time. All wanted is to connect them in a virtual network. This will allow me to create a server(using python sockets) in a virtual machines and other VMs act as clients. Is my idea possible? if possible How can I do it.

Im not sure if this help but your question doesnt really help either.
So the last time I used vmware was for virtual machine. I think it was called wmware workstation 12. I used the free version which lets you use it for noncommercial use. If you are using that then this most likely applies.
So because its not the pro or commercial version you can only open one virtual machine at a time. But from your question seems like your using python. Not sure what that means. But what i am trying to say is if its the free version then you may only be able to open one virtual machine at a time.
This maybe the problem your having.
I hoped this helps, if not you then someone else.
EDIT
Here is a few youtube video i have found that will help to make a virtual network. You need to make a host-only network. May wish to turn on dhcp. Once your created the virtual network. All the vms need to use the same virtual network. Now that your vms are on the same network and are able to communicate with each other hopefully your python script should work. Im not sure how to use pyhton. Otherwise would have provided code to open a simple socket and test it from client side. Anyway im sure you could your script correctly and it should work now. You may need to use ipconfig (windows cmd)/ifconfig (unix terminal) to find the ip address of the server machine.
https://www.youtube.com/watch?v=8VPkRC0mKF4
https://youtu.be/vKoFSmy3agM?t=131
Here is link to simple python server
https://www.tutorialspoint.com/python/python_networking.htm
the host variable in the client code should be the ip of the server and not gethostname. so use ifconfig/ipconfig on server to find the server ip.
👍

Related

Make python Flask application accessible from the Internet with gunicorn

what I have:
I made a simple web application using Flask, which woks great on the localhost.
what I want to achieve:
I want to deploy it so it is visible in the internet.
Because Flask says that the production server should not be used for deployment I installed gunicorn.
I managed to get it working on localhost (running gunicorn server:app).
Then I tried to make it public using the -b 0.0.0.0:5000 option. it said it is running on 192.168....:5000 Now I could access the website using that ip address from my computer and also from my phone connected to the same wifi. however I was unable to connect to the website when I didn't use this wifi.
when I searched about this, I found out that the 192.168.... ip address range is reserved to the local network and cannot be accessed from anywhere else.
how do I need to run the script so it is accessible from everywhere? Do I need to modify the firewall settings? Maybe there is a better way to deploy such an app on the local machine using a different framework?
Just some additional information:
python version: 3.9
I am using a venv (and installed flask and gunicorn into it)
os: macos 11.6.1 (I could run it on an Ubuntu machine if that is easier)
This question isn't anything related with Python or Gunicorn but to networking (so maybe StackOverflow isn't the correct place to ask but other community like ServerFault)
Currently your application is already exposed on your machine in the defined port, so next step would be to forward all the traffic that comes to your router to there.
In order to do that, you will have to configure the firewall of your router to accept incoming traffic through a desired port and finally forward the traffic which comes from that port to your machine in the port 5000.
Also, in the case that you have everything already configured, it will only work if your ISP is providing you a single IPv4, what currently doesn't happen anymore but you actually are sharing that with few more people. Other option would be that you configure IPv6 incoming traffic.
As you can see, this isn't a simple task neither one that should be done without proper care, since you would be literally opening your network to possible attackers.
So, in order to simplify it at the most for you, since you already have Gunicorn, I would recommend you to use any of the resources exposed by other users as Heroku or Netlify which are free for a single application and will fulfill your expectations without requiring high amount of networking knowledge.
You would need to do the following steps:
read up and learn a lot about security for Web servers, then read some more, it is fraught with risks
find your Mac's IP address on your local network and make sure it is fixed, i.e. set as static on your Mac (under "System Preferences->Network") or reserved in your router's DHCP tables (by putting your Mac's MAC address in its allocation tables) so that it always gets the same local address on your internal network when it boots
log into your router and set up "Port Forwarding" to forward external requests (coming from the Internet) for port 5000 (or some other port) to your Mac's fixed IP address and the port 5000 where Gunicorn is serving
log into your router and find your WAN IP address, or go to http://whatsmyip.com to get the address you need to put in your browser, or your friends need to put in their browsers to see your shiny new website
as it stands, this will work until the next time your router reboots when your ISP will likely allocate it a new IP address. If you want it permanent, you need to either 1) ask your ISP for a static IP address, or 2) subscribe a DDNS service (e.g. noip.com or dyndns.com) or 3) tell your friends your new IP address every time you reboot your router
I do not know anything about gunicorn. But what I used to use when needing to deploy a flask app was pythonanywhere. They have a great and totally free hosting service. It's really fast in deploying, needs no resources from your computer and is just great. Also you would have to forward the port 5000 for your computer to enable other devices not in the same network to access your computer/flask app. That comes with security issues. However, you do not need any of that when using pythonanywhere.
There are also other great hosting services like that one. It's just the only one I know and used yet but you'll find others for sure if you don't like that one.

Running Python scripts on an Ubuntu machine disables the network port

One of the Ubuntu machines I manage is having an issue where it completely disables the network port every time I run a Python script on it. It does not matter what the script is, after about 5 minutes of execution, the network show as unreachable. I have tried disabling and re-enabling the network via the terminal but this does not bring the port back online. Even doing a normal reboot does nothing, I have to physically unplug the machine to get it to come back up. Has anyone had this problem before?
Edit: Linux version 4.15.0-99-generic (gcc version 7.5.0). The network is a domain with this computer hooking up via a dynamic IP linked to a static IP router. This is only one of about 50 Linux machines we (college IT staff) manage and this is the only one that has ever done anything like this. Other computers in the same room with the exact same network setup run scripts perfectly.
See https://docs.python.org/3.8/library/socket.html#example and read the part where it talks about why you need to use SO_REUSEADDR.

Python communicate into VM windows app

How can I setup a virtualized Ubuntu on real Windows so I can have two apps communicating simple messages between them? VM can be offline, no internet access. Real system probably offline too.
Host<->VM communication on Windows host can be implemented in several ways, independently of hypervisor you are using:
Host Only network - just assign static IP for host and machine, and use sockets api to transfer your data via virtual network. Very good for large amount of data, but require a little bit time for configuration.
Virtual COM ports - if you don't want to use sockets api and want to write data to files(on linux VM)/named pipes(on windows host). This can be simpler because require almost zero configuration, but it will not work very well with large amount of data.
Choose what will fit your needs.

Why does python SimpleHTTPServer not work on localhost when there is no internet?

I ran python -m SimpleHTTPServer to create a web server session (on Windows 8). This works fine using http://127.0.0.1:8000 or http://localhost:8000 UNLESS there is no internet connection. When there is no internet the (Chrome) browser stays blank. How to make the local server work regardless of whether there is external internet connectivity? Is this a Windows specific issue?
If this is what I think it is, you're testing by unplugging the network cable or turning off your wireless card.
When there is no network, in many Windows versions, the entire network stack, or at least the user space part of it, goes away.
You might hunt up a loopback adapter pseudo net card and install that, which will give you an always active network connection; I believe Microsoft did make one available for Windows 7 and earlier, but I haven't looked for it on Windows 8.

Execute vbs script (that does double hop) in remote windows machine from linux using Pywinrm

I need to run a vbs script in Windows machine from a Linux machine. I used Pywinrm to achieve the connection between Windows and Linux. The vbs script has a set of installation in it. Is there anyway I can run this vbs script without having to use "CredSSP" authentication?
Yes, you can use kerberos in a double hop scenario initiated using pywinrm. A minor patch needs to be made to pywinrm in order to get forwardable kerberos tickets, which is outlined here:
https://github.com/diyan/pywinrm/issues/58
You will need to perform SPN registration as needed for the services you are connecting to on the second hop. You'll also need to configure the computer account of the first hop to be trusted for delegation to the desired services using kerberos.
Good luck!

Categories

Resources