Create hard disk
Disk file type -> VDI
Dynamically allocated
Set Storage size = 30G
settings
General -> Advanced[Shares Clipboard,Drag & Drop] -> Bidirectional
Storage -> IDE optical disk -> monut linux iso file
choose CentOS-7-x86_64-bin-DVD-1804.iso https://www.centos.org/download/
CentOS-7-x86_64-bin-DVD-1804.iso mounted
網絡設定:
方案一:Network -> Adapter1 -> enable NAT network adapter
然后利用 Host 进行对外的连接
返回的数据包再由 NAT Engine 传给 Guest
Host 可以上网,Guest 就可以上网
Guest 之间不能互 ping
Guest 可以 ping Host(此时 ping Guest 的 gateway,即是 ping Host)
Host 不能 ping Guest
方案二:Network(網絡)à Adapter1(網卡1) à Bridged networking(橋接網卡)
通过 Host 网卡,架设一条桥,直接连入到网络中
使得 Guest 能被分配到一个网络中独立的 IP,所有网络功能完全和在网络中的实体机器一样
Guest 是通过 Host 所在网络的 DHCP 服务得到 IP
理论上两者是完全独立的,但实际因 Guest 无独立硬件,仍要靠 Host 的网卡,因此 Host 断开网络,Guest 也无法拿到 IP
Host 可以上网,Guest 就可以上网
Guest 之间可以互 ping
Guest 可以 ping Host
Host 可以 ping Guest
如果无法自动获得IP,需配制 动态 IP 配制
[root@localhost]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=08:00:27:51:2A:A0
TYPE=Ethernet
UUID=2df6aa6c-145b-4fbb-aa4b-bdcaf6827ee1
ONBOOT=on # 改为 yes 启动开机自启获取 ip
NM_CONTROLLED=yes
BOOTPROTO=dhcp
## 重启动IP配制
[root@localhost]#service network restart
或设定静态 IP 配制
[root@localhost]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=08:00:27:51:2A:A0
TYPE=Ethernet
UUID=2df6aa6c-145b-4fbb-aa4b-bdcaf6827ee1
ONBOOT=on # 改为 yes 启动开机自启获取 ip
NM_CONTROLLED=yes
#BOOTPROTO=dhcp
BOOTPROTO=static -->IP方式
IPADDR=192.168.1.102 -->静态IP
NETMASK=255.255.255.0 -->子网掩码
GATEWAY=192.168.1.2 -->网关地址
## 重启动IP配制
[root@localhost]#service network restart
Linux解决Device eth0 does not seem to be present,delaying initialization问题
引用: https://blog.csdn.net/baidu_41617231/article/details/90372507
- Adapter2(網卡2) à Host-only Adapter(僅主機網絡)
通过 VirtualBox Host-Only Network 虚拟网络卡进行通信,VirtualBox 以此 IP 作为 gateway,因此模拟了一个 Host 与各个 guest 的局域网络
需到偏好设定加入虚拟网卡,才可使用
Guest 不可以上网
Guest 之间可以互 ping
Guest 可以 ping Host
注意 Guest 与 Host 是通过 Host 的 VirtualBox Host-Only Network 虚拟网络卡,因此 IP 是该网卡 ip,非目前上网所用 IP
Host 可以 ping Guest
- Install Linux centos -> Start
- Install CentOS 7
Setup timezone
Choose Region & City -> Done
Setup network & hostname
Ethernet switch “ON“ -> Done
Setup root password
Key in password -> Done
Continue to install
Complete -> Reboot
Root login
# ip a
All NAT network cards on the VM are the same IP: 10.0.2.15
Back to Virtualbox console -> Settings
Network -> Advanced -> Port Forwarding
Add new rule
Input host ip & port, guest ip & port -> OK
- OK , The forward setting takes effect immediately, without reboot