1、 Background
Recently, I have been learning some technologies. In the process of learning, I found that writing technology needs to build a cluster environment, but I don’t have so many local machines and it’s expensive to buy virtual machines. Therefore, I want to build several virtual machines to learn. This article mainly records the configuration of virtual machine network in virtual box.
2、 Demand
1. External network can be connected in virtual machine.
2. The host and virtual machine can communicate with each other.
3. Virtual machines and virtual machines can communicate with each other.
2、 Set up the network of the virtual machine
1. Create a global NAT network
2. Add host network manager
3. Set up virtual machine network
1. Network card 1 set NAT network
2. Network card 2 set host network
4. Start virtual machine set virtual machine IP
Set static IP
vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
Enp0s8: This is the name of the network card, which is the name of the red box in the figure above.
The ifcfg-enp0s8 configuration file may not exist, but we can copy it from ifcfg-enp0s3.
When copying, it should be noted that there is a UUID value in the configuration file, which needs to be modified and cannot be consistent.
After configuration, restart the network card
service network restart
5. Test whether you can connect to the Internet
6. Host access virtual machine
Now you are ready to configure the network of the virtual machine in the virtual box.