After installing VirtualBox, install centos7. I won’t repeat it here. There are many tutorials on the Internet
First shut down the virtual machine and configure the network according to the following settings
Here we need to use dual network card. We are opening the second network card, as shown below
After that, start the virtual machine and perform the following operations
#Enter the directory where the network card is located cd /etc/sysconfig/network-scripts/ #Backup network card information cp -rp /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-enp0s3.bak #Editor VI / etc / sysconfig / network scripts / ifcfg-enp0s3, as follows TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="dhcp" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="enp0s3" UUID="ee340a0f-1557-49c7-a927-5069c4e2ab88" DEVICE="enp0s3" ONBOOT="yes"
The above configuration is the information of network card 1 that we added. We are copying the information of network card 2
cp -rp /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-enp0s8 TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="enp0s8" UUID="cb7e712d-c2db-4dee-8950-37f9d8a780e9" DEVICE="enp0s8" ONBOOT="yes" IPADDR="172.21.208.200" NETMASK="255.255.252.0" GATEWAY="172.21.208.1" DNS1="188.8.131.52"
matters needing attention:
UUID should be changed to your own. It can be generated by using uuidgen command. Note that IPADDR, netmask and gateway in enp0s8 are not scribbled. Because our network card 2 chooses the bridge mode, that is to say, it is equivalent to connecting the virtual machine and the host to the same network environment, so you need to check the configuration of the host, use Win + R, type CMD + enter, open the DOS command line, and enter ipconfig / all You can view the network configuration in the host as follows
If you look carefully, the network segment configured in NIC 2 is the same as that on the host. You can use xshell to connect the IP in NIC 2
The above is the method and precautions of virtualbox6 installing centos7 to set static IP. I hope it can help you. If you have any questions, please leave me a message and Xiaobian will reply you in time. Thank you very much for your support to developer!
If you think this article is helpful to you, please reprint, please indicate the source, thank you!