目標(biāo):在Windows上快速創(chuàng)建一臺能ping通局域網(wǎng)及公網(wǎng)的centos7虛擬機(jī)
1 下載并安裝附件中的軟件
先安裝VirtualBox:www.virtualbox.org/wiki/Downlo…
再安裝Vagrant:www.vagrantup.com/downloads.h…
下載需要的box:app.vagrantup.com/boxes/searc…
以上資源我百度云也提供了一份:https://pan.baidu.com/s/1_dkzDme_4ZoCWJuYqg9sCQ 提取碼:4fv1
2 進(jìn)入目錄 D:\vm\centos7 ,里面放centos-7.0-x86_64.box

在當(dāng)前目錄打開Git Bash,使用命令:vagrant box add centos7 centos-7.0-x86_64.box把box添加到vagrant

3 創(chuàng)建虛擬機(jī)
進(jìn)入目錄:D:\vm\centos7\centos7-vm-1
使用命令:vagrant init centos7

會發(fā)現(xiàn),當(dāng)前目錄生成了一個文件 Vagrantfile,文件內(nèi)容為
Vagrant.configure("2") do |config|
config.vm.box = "centos7"
end
在文件中給虛擬機(jī)配置固定IP地址
Vagrant.configure("2") do |config|
config.vm.box = "centos7"
config.vm.network "private_network", ip: "192.168.0.100"
end
4 啟動虛擬機(jī)
進(jìn)入目錄:D:\vm\centos7-1\centos7-vm-1
使用命令:vagrant up (等待一兩分鐘)

啟動成功后??梢栽贠racle VM VirtualBox 界面上,看到虛擬機(jī)

可以在D:\vm\centos7\centos7-vm-1 目錄下,使用vagrant ssh 。連接進(jìn)入虛擬機(jī)

查看IP可以看到是我們配置的IP

window中也可以ping通這個IP

5 虛擬機(jī)的關(guān)閉
暫停 vagrant suspend
停止 vagrant halt
銷毀 vagrant destroy
6 其他問題
6.1 賬號密碼:
默認(rèn)賬號密碼 vagrant/vagrant
如果需要root權(quán)限。使用sudo即可
6.2 共享目錄:
D:\vm\centos7\centos7-vm-1 與 linux的 /vagrant 中的目錄。是共享的。