Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I sometimes use python -m SimpleHTTPServer one liner to serve files from my vms for download to my host. Today i tried to use it inside virtualbox vm that is under NAT network settings - i typed this python one liner in console, then i checked what ip my vm has in knetworkmanager (i use debian with kde on my guest), then on host i tried to connect to that ip on port 8000 but i can't connect...

My guests are often paused, saved, etc... maybe ip should change but something went wrong because guest was saved and then restored? Any ideas what to do with that?

I'm using debian linux guest and debian linux host.

share|improve this question

closed as off-topic by Michael Hampton Nov 28 '15 at 10:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.

To get the port redirect try the following

VBoxManage setextradata "NAME_OF_VM" "VBoxInternal/Devices/e1000/0/LUN#0/Config/pythonhttp/HostPort" 8080
VBoxManage setextradata "NAME_OF_VM" "VBoxInternal/Devices/e1000/0/LUN#0/Config/pythonhttp/GuestPort" 8000
VBoxManage setextradata "NAME_OF_VM" "VBoxInternal/Devices/e1000/0/LUN#0/Config/pythonhttp/Protocol" TCP

This configuration works is for virtual Intel network cards. For the PCnet try pcnet instead of e1000. And I assume that the port in virtual machine is 8000. Remember to change NAME_OF_VM to the name of your virtual machine!

After this you can access the webserver on the host system via http://localhost:8080/ which will be redirected to the virtual machine with the port 8000.

You can check the configuration with VBoxManage getextradata "NAME_OF_VM" enumerate. To remove the configuration type the command without the values.

VBoxManage setextradata "NAME_OF_VM" "VBoxInternal/Devices/e1000/0/LUN#0/Config/pythonhttp/HostPort"
VBoxManage setextradata "NAME_OF_VM" "VBoxInternal/Devices/e1000/0/LUN#0/Config/pythonhttp/GuestPort"
VBoxManage setextradata "NAME_OF_VM" "VBoxInternal/Devices/e1000/0/LUN#0/Config/pythonhttp/Protocol"
share|improve this answer
    
doesn't work, i can't connect to localhost on 8080 – Phil Nov 24 '09 at 17:21
    
Can you post the output from VBoxManage getextradata "NAME_OF_VM" enumerate? Did you set the right Network Interface (Intel or PCnet)? – cwo Nov 25 '09 at 12:28

If your vms are NATed they have a virtual IP in a private network (RFC1918 IP range), so they are not routable and accessible from outside.

In order to make a NAT-ed machine reachable from outside you have to implement a PORT REDIRECT on the virtual gateway, mapping a request on a given port to be redirected to the virtual IP on the given port or another.

This is not a virtualization bound issue, this is how NAT works. So any guide on the topic you'll find on the web will apply.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.