Is it possible to make localhost work through a Virtual Machine? - macos

I am using a Macbook running 10.6. I am using VMware Fusion to run an Ubuntu Server minimal virtual machine. Ubuntu Server is running your basic LAMP stack.
I do my development in Mac OS. I have VMware share a directory from Mac OS to the Ubuntu Server. Ubuntu Server uses that directory for apache.
I access my server is Mac OS in firefox using the ip address of my virtual machine. This is a pain because I have to find out what the ip address is of my virtual machine each time I boot it up. I could set a static ip address but this causes problems if I move my Macbook from network to network.
Is there any configuration (NAT or Bridged or something) that would let me access my virtual machine from the Mac OS using localhost or something similar?
Thanks

NAT should be OK. Your VM is on a different subnet that way, you can give it the static IP you like, and it won't interfere with the (dynamic) IP on your real network.

What you are looking for is the host-only networking adapter as opposed to the NAT or bridged adapters. This creates a network interface on the virtual machine that only connects the actual host. It is perfectly safe to set an IP address for this interface that does not change, and there will be no tricky NAT getting in the way. It's a little network that only exists for communication between the real host and the virtual host. It's exact purpose is so you can do development like this. I use the same feature on VirtualBox all the time, but VMWare has it as well.
Now, with a host-only adapter you might be worried that your VM now has no access to the Internet. The answer is simple. Just make two adapters. eth0, eth1. Make one of them a bridged or NAT adapter for Internet access. Make the other one the host-only adapter for your development. Most modern Linux distros will automatically route accordingly. I know for a fact that Ubuntu does, because I do it all the time. Again, this is with VirtualBox. Your mileage may vary with VMWare, but I can't imagine it's that different.

I'm using Virtual Box and typing in the computer local address (for instance 192.168.1.100) instead of localhost did the trick.

Maybe I'm misunderstanding your question but why not just add an entry in your hosts file for the virtual machine? That way you can access it with some arbitrarily assigned name (like testmachine) instead of the IP.
This is the first tutorial I found through google: http://decoding.wordpress.com/2009/04/06/how-to-edit-the-hosts-file-in-mac-os-x-leopard/
This would work best if your VM has a static IP, BTW (either no DHCP or configure the DHCP server to give that MAC the same IP every time). That way you don't have to worry about changing the hosts entry every time the DHCP server gives the VM a different IP.

Related

Can ping server, but not browse

I'm trying to set up a personal cloud server on a Surface Pro, but I'm running into a networking issue that has me completely stumped.
My setup looks like this: I've installed a Nextcloud server on a VMWare virtual machine that's running Ubuntu 16.04, and I have it configured to use NAT so the virtual machine shares a fixed ip address with the host machine. I've forwarded ports 80, 443, etc. on the host machine's NAT device so requests go to the virtual machine. Additionally I've configured my router to have a static ip address, and I've forwarded all the relevant ports to the Surface Pro on my router.
So the trouble is that I can't connect to my server from my browser. HOWEVER, I am able to ping my server, I can SSH in to both the virtual machine and the host machine from the internet, and I am able to access the server in my browser from any computer that's connected to LAN, no problem.
This all sounds like it could be a firewall issue to me (maybe port 80 is blocked on the host machine for some reason??) but the fact that I have no trouble accessing the server from LAN is confusing the issue, and also deactivating the firewall on the host machine doesn't solve the issue.
Any thoughts?
I solved the problem! It turns out the NAT device was improperly configured to use its own DHCP service rather than using the local DHCP service. Basically it was assigning a LAN IP address 169.254.72.176 to the virtual machine, while everything else was configured to expect that the virtual machine's IP address was fixed at 192.168.34.43.

Access xampp from VMWARE to Public IP

Is it possible to access 127.0.0.1:8080 publicly i have a project application that is running on VM, What should I do?
Diagram:
VMachine( where xampp is installed) IP <-> Global(external) IP (167.1.174.21:8080)
I don't have any option left what should i do i'm really new to this. #respect
Yes, this is possible but there are multiple steps to the configuration and the details for each steps differ depending on the hardware/software used. In general though it can be accomplished like this:
VMware config
Configure the VM with a bridged network
Configure the guest OS to either have a dhcp reservation or static ip.
Router config
Add a dhcp reservation for the VM (if using DHCP)
Add a port forwarding rule pointing to the VM's IP address
XAMPP config
Make sure the XAMPP server is listening on all interfaces.
The key point is to make the Virtual Machine to have bridged connection.
You can do it by looking at this one.
After that do a Port Forwarding to the virtual machine like it a real machine on your LAN.
Step 1 : Apart from above solution, in your local network where xampp is installed, make your local ip as static one, like "192.168.1.125" from router settings->Address reservation option.
Once you reserve address
Step 2 : Open your router->port forwarding->set port & ip to forward.
Step 3 : Now you check your public ip, and bingo now you can go to your public ip from vmware or from any other network.
As long as the vm has a configured network and is therefor able to communicate with your LAN (using Bridged networks in the VM configuration is a good way to go) and the internet, it is possible to make it accessible to the external web/internet.
Therefor you would most likely need to define a port-redirect/port forwarding on your router, that all incoming packets on the external IP (167.1.174.21) on port 8080 gets forwarded to the local ip of your vm and the related xampp session.
A possible problem at that point might be changing IP addresses of the VM based on a possible DHCP configuration. Either use a fixed IP on the VM or configure some mac-based rule for fixed IP or increase the lease time of the dhcp-server (your router to unlimited)
That's the theory, but please think twice before you do so. Running a webserver which is available in the wild is not recommended if you are not used to IT security. And even if you decide to do so, using xampp sounds wrong to me ears. xampp is designed for local development & testing purposes, not for productive use.

How to set the IP Address of a Virtualbox guest manually

For sake of automation I need to be able to manually set the IP address of my Virtualbox guest (which is an OS X) to a fixed IP.
Can this be done using VBoxManage? I need to avoid the GUI.
Thanks
in your virtual machine setting, you can find networking adapters. You have some choice :
Network Address Translation (NAT): Used to share the host's IP address
If all you want is to browse the Web, download files and view e-mail inside the guest, then this default mode should be sufficient for you, and you can safely skip the rest of this section.
Bridged networking
This is for more advanced networking needs such as network simulations and running servers in a guest. When enabled, VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack.
Host-only networking
This can be used to create a network containing the host and a set of virtual machines, without the need for the host's physical network interface. Instead, a virtual network interface (similar to a loopback interface) is created on the host, providing connectivity among virtual machines and the host.
if you want specific IP for your virtual machine you can set in your guest vm ( ifconfig in linux & ipconfig in windows) and choose NAT in network adapter setting .
https://www.virtualbox.org/manual/ch06.html

Cannot ping ubuntu VM from mac os

I have an ubuntu VM running in VirtualBox. I am trying to ping it, but cannot. I have the network setting changed from 'NAT' to 'bridged'.
here is the screenshot of the ip address info:
and here is the result of a ping....
i did some google searching, but have not been able to pinpoint the issue yet.... thanks
When you use NAT mode, you will never ping the virtual machine from the host machine because it is the NAT restriction. But when you use the bridged mode, you should be able to ping the virtual machine because it will create a direct path as if both of the machine directly connected. If the ping is fail, perhaps there is some program or application that are blocking the network like a firewall.

Virtual IP Address

I am developing an application related to networking . Its prerequisite is that the machine must have an ip address to function properly.
When i am on my home network , my machine gets the IP address through DHCP present on my network. However, when my machine is in stand alone mode e.g. while travelling i can not have an ip address and the status is LAN DISCONNECTED.
Is there a workaround so that i can get an ip address or virtual ip address in standalone mode?
I have already tried configuring with loopback address and other ip address.
Can I do it by installing a dhcp server on my machine? My system uses WINXP?
Network card: BroadcomNetxtreme 57XX gigabit ethernet.
I strongly feel that the application details have nothing to do with it. Since, when the machine has an ip address it starts working properly.
Still i am open to ideas.
I advise you to work inside a virtual machine, and then assign a virtual IP and vitual MAC of your convenience. You can use Virtual Box or VMWare.

Resources