The difference between private and public networks

In a private network, the host serves as a layer router. Computers on the same network segment as the host cannot directly access the VM. The VM and the host are on another network

Private network

The folder for creating the VM is displayed

Modify theVagrantfilefile

find



To get rid ofConfig.vm.net work "private_network", IP: "192.168.33.10"In front of#, the configuration is complete

For the configuration to take effect, restart the virtual machine and type Vagrant Reload on the terminal



The IP address here is equal toVagrantfileAs configured in the file,

You can also view the IP address of the host



You can find that the IP address of an Ethernet configurator is in the same network segment as the VM

The public network

The folder for creating the VM is displayed

Modify theVagrantfilefile

find



To get rid ofconfig.vm.network "public_network"In front of#, the configuration is complete

To make the configuration take effect, restart the VM and enter a value on the terminalvagrant reloadIn this case, it will let you choose which network card to bridge to. In this case, I choose WiFi, so I choose wireless network card. In this case, the VIRTUAL machine and the host computer are in the same network segment



192.168.31. *It is the LAN port network segment of my router. The VM IP address is assigned by the DHCP service of the router