Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access private VM from other computer over wifi

Tags:

vagrant

puppet

I have a private network VM for developing on my mac. I'd like for my android device to be able to communicate with the VM on my mac. Currently I can visit the IP defined in my Vagrantfile, 10.10.10.10, on my mac and access it just fine but I can't access it via my phone on the same wifi.

What do I need to do to make it available across my local network and visible to my phone over wifi?

Here's my Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"

  config.vm.network :private_network, ip: "10.10.10.10"
    config.ssh.forward_agent = true

  config.vm.provider :virtualbox do |v|
    v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    v.customize ["modifyvm", :id, "--memory", 1024]
    v.customize ["modifyvm", :id, "--name", "PHPBoxWith54"]
  end

  nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/
  config.vm.synced_folder "./", "/var/www", id: "vagrant-root" , :nfs => nfs_setting
  config.vm.provision :shell, :inline =>
    "if [[ ! -f /apt-get-run ]]; then sudo apt-get update && sudo touch /apt-get-run; fi"


  config.vm.provision :shell, :inline => 'echo -e "mysql_root_password=root
controluser_password=awesome" > /etc/phpmyadmin.facts;'

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "manifests"
    puppet.module_path = "modules"
    puppet.options = ['--verbose']
  end
end
like image 330
David Avatar asked Sep 08 '13 21:09

David


People also ask

Can I access my virtual machine from another computer?

By setting up Workstation as a server, you can access the same virtual machine from different computers and use the processing power of the server to run the VM.

How can I access files from another computer on the same wifi?

Open File Explorer and select a file or folder that you wish to give other computers access to. Click the “Share” tab and then choose which computers or which network to share this file with. Select “Workgroup” to share the file or folder with every computer on the network.

How can I access my server from outside my network?

Use a VPN. If you connect to your local area network by using a virtual private network (VPN), you don't have to open your PC to the public internet. Instead, when you connect to the VPN, your RD client acts like it's part of the same network and be able to access your PC.


1 Answers

You are using a Private Network IP which is only accessible by the Host machine (NOT visible to other machines even they are in the same WLAN).

In your case, the best choice is to use Public Network (bridged) so that your Android device can access it.

add config.vm.network "public_network" in your Vagrant file in the config block.

BTW: the default NAT mode is fine but you'll have to set proper port forwarding rules for each service you want to access (e.g. SSH, HTTP, HTTPS etc...).

like image 183
Terry Wang Avatar answered Sep 20 '22 05:09

Terry Wang