Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As a web developer, what is the most efficient (automated) way to connect to a virtual machine (VM) running a development webserver from its host machine (the machine running the VM) when you do not have control over the networks (home, Starbucks, work, etc) you are connected to?

Currently I start my VM (a VirtualBox VM running CentOS), run ifconfig to determine the VM’s current IP. I then take that IP and map it to my Host machine’s host file so that I can access the VM’s webserver from the Host.

I feel that this is not an efficient way to connect to my VM’s webserver because each time I connect to a new network (a few times a day) I need to repeat the IP lookup and host file update, and sometimes restart the VM's network service.

share|improve this question

closed as not a real question by Canadian Luke, ChrisF, Journeyman Geek, Diogo, BBlake Oct 31 '12 at 12:10

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Thank you for flagging my question as ‘not a real question.’ I have read through the FAQ and see that my question was vague and poorly articulated. I have reworked my question in an effort to help find an answer from and for the community. I am a new contributor to the Superuser community, if my question is still vague please provide feedback or help better my question or suggest another forum/site (maybe webmaster or serverfault) where it should be asked? However, I believe this question specifically applies to computer hardware, computer software, personal and home computer networking. –  Jonnybojangles Oct 31 '12 at 16:54
The difference I see between this question and a few others asked on the site is that I do not have control over the router on some networks. –  Jonnybojangles Oct 31 '12 at 16:58
First, set your networking mode to "Host Only". For more info, see: virtualbox.org/manual/ch06.html. Then, give your VM a static IP on the interface which is host-only. Enter that IP in your laptop host file; you can then access the VM at that IP forever; it will not change. If you need your VM to be accessible by other computers/connect to the internet, add a second virtual NIC to the VM in "Bridged" or "NAT" mode. That interface will behave like the current one does--getting a new IP often, but your laptop will still connect using the static host-only interface, rain or shine. –  Zac B Oct 31 '12 at 17:05
@ZacB That sounds like a solid solution. I am trying to implement it now. However, I have an issue getting the VM to accept the 'Host Only' Network connection. I receive an "Invalid Settings Detected" error that does not allow me to save the VM's settings. I will research/resolve this error and try to get you an accepted answer. –  Jonnybojangles Oct 31 '12 at 17:37
Resolution to Host Only Invalid Settings: superuser.com/questions/429405/… –  Jonnybojangles Oct 31 '12 at 17:46
show 1 more comment