On the Mac VirtualBox installed Centos7 set a static IP and the Internet

Virtualbox installed with three Centos7, now we need to be arranged to communicate with each other between three and three are connected to external networks.

Requirements are as follows:

1. Three communicate with each other inside

2. Can the external network

3. The host can communicate with each virtual machine may (shell can be connected)

The first step in virtualbox preferences in settings Add NAT network

Preferences -> Network -> right click the plus sign to add a NAT network.

 

The second step in the management virtualbox find toolbar, add only-host

Toolbars -> Administration -> Host Network Management -> Create to create a complete click ok.

 

Step Click Settings in the installed centos

Settings -> Network -> Add two cards, namely NAT network, only the host (HOST-Only) networks.

After the above done, start Centos, into the management interface, edit the appropriate configuration file.

The following configuration files in this directory: / etc / sysconfig / network-scripts /, the default network configuration file is: ifcfg-enp0s3

Ifcfg-enp0s3 edit this file, which will be ONBOOT = no change ONBOOT = yes

Exit save and restart the network. Exit is: wq, restart the network service network restart

This time you can communicate with external networks, ping about Baidu try

At this point, it has been in communication with the external network, but this time also dynamic ip, is the same way with the host, but need a static ip, that we add a second network cards, this time to set up a static ip.

NAT card above the corresponding file is ifcfg-enp0s3, it will copy the file, change the ifcfg-enp0s8

Copying, cp copy command ifcfg-enp0s3 ifcfg-enp0s8

After copying, this time to edit the ifcfg-enp0s8 this file, modify the configuration of some of them.

There needs to be modified

  BOOTPROTO=dhcp 改为 BOOTPROTO=yes

  NAME = enp0s3 to NAME = enp0s8

  DEVICE=enp0s3 改为 DEVICE=enp0s8

  UUID 也需要修改,UUID可以重新生成一个,直接在命令行输入 uuidgen,回车就会出现结果,把结果复制过来。

添加

  IPADDR=192.168.56.119 (根据添加的第二网卡的ip范围内即可,一搬是 192.168.56.101——192.168.56.255)
  NETMASK=255.255.255.0

设置完成之后,保存退出。重新启动网络,这个时候静态ip也有了,可以在次尝试ping一下相应的网络。

ping 192.168.56.1 (网关是通的)

ping 192.168.56.119 (自己)

通过宿主机的终端来ping虚拟机,看看两者是否通信,结果是通信的,一切ok。

以上就是virtualbox设置静态ip,并实现相互通信的整个过程。 

 

Guess you like

Origin www.cnblogs.com/hanwen1014/p/10983449.html