Vagrant Modify configuration file to access virtual machine configuration via IP

Source: Internet
Author: User

The Vagrantfile file in the virtual machine directory is a vagrant configuration file, and if you want to use the virtual machine as a server, you can access it via IP, and you need to modify the configuration file to configure it. This machine is using vagrant under Windows, in the process of configuration encountered problems, recording the resolution process.


Open the Vagrantfile file in the virtual machine directory and specify a private_network, as follows:

# Create a private network, which allows host-only access to the machine
# using a specific IP.
Config.vm.network "Private_network", IP: "192.168.10.31"

This specifies that the access IP for this virtual machine is 162.168.10.31.

Then in the terminal input: Vagrant reload command, restart the virtual machine, load the new configuration, but after the reboot to access this IP address, unable to access.

Open the Control Panel network and discover that multiple virtual network adapters are started:

I have the name VirtualBox host-only network with a numbered NIC to disable, and then reboot the first network card, again access to 192.168.10.31 or inaccessible. Right-click the first network adapter property and find that the address of the IPv4 configuration is not set to 192.168.10.31, but is otherwise, manually changed to the configuration file specified.

Access the server that 192.168.10.31 successfully accessed to the virtual machine again. You can also add a host locally, bound domain name access.

Another important configuration item for the Vagrantfile file is:


Config.vm.synced_folder "D:/xampp/htdocs", "/usr/share/nginx/html"

It represents a directory where Windows local directories are mapped to virtual machines.

So when you visit 192.168.10.31, you are accessing the directory on Windwos, which is the Web root directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.