目标:在Windows上快速建立一台能ping通區域網路及公網的centos7虛拟機
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 進入目錄 D:\vm\centos7 ,裡面放centos-7.0-x86_64.box

在目前目錄打開Git Bash,使用指令:vagrant box add centos7 centos-7.0-x86_64.box把box添加到vagrant
3 建立虛拟機
進入目錄:D:\vm\centos7\centos7-vm-1
使用指令:vagrant init centos7
會發現,目前目錄生成了一個檔案 Vagrantfile,檔案内容為
Vagrant.configure("2") do |config|
config.vm.box = "centos7"
end
在檔案中給虛拟機配置固定IP位址
Vagrant.configure("2") do |config|
config.vm.box = "centos7"
config.vm.network "private_network", ip: "192.168.0.100"
end
4 啟動虛拟機
進入目錄:D:\vm\centos7-1\centos7-vm-1
使用指令:vagrant up (等待一兩分鐘)
啟動成功後。可以在Oracle VM VirtualBox 界面上,看到虛拟機
可以在D:\vm\centos7\centos7-vm-1 目錄下,使用vagrant ssh 。連接配接進入虛拟機
檢視IP可以看到是我們配置的IP
window中也可以ping通這個IP
5 虛拟機的關閉
暫停 vagrant suspend
停止 vagrant halt
銷毀 vagrant destroy
6 其他問題
6.1 賬号密碼:
預設賬号密碼 vagrant/vagrant
如果需要root權限。使用sudo即可
6.2 共享目錄:
D:\vm\centos7\centos7-vm-1 與 linux的 /vagrant 中的目錄。是共享的。