最近在mac电脑上使用vagrant搭建虚拟机,使用的box为centos7.8。Vagrantfile配置私有网络【如下】,在本地通过ip无法访问?
config.vm.network "private_network", ip: "192.168.33.10"
→ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.2.42
default: VirtualBox Version: 6.1
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /Users/michael/Desktop/vagrant
==> default: Machine already provisioned. Run vagrant provision
or use the --provision
==> default: flag to force provisioning. Provisioners marked to run always will still run.
→ ping 192.168.33.10
PING 192.168.33.10 (192.168.33.10): 56 data bytes
64 bytes from 192.168.33.10: icmp_seq=0 ttl=64 time=0.367 ms
64 bytes from 192.168.33.10: icmp_seq=1 ttl=64 time=0.502 ms
64 bytes from 192.168.33.10: icmp_seq=2 ttl=64 time=0.362 ms
64 bytes from 192.168.33.10: icmp_seq=3 ttl=64 time=0.277 ms
64 bytes from 192.168.33.10: icmp_seq=4 ttl=64 time=0.630 ms
通过192.168.33.10/index.html无法访问。浩哥,这个是什么原因?