How to set static IP in CentOS7 on VirtualBox6 and what to note

How to set static IP in CentOS7 on VirtualBox6 and what to note

Install CentOS 7 after installing VirtualBox. I won’t go into details here. There are many tutorials online.

Shut down the virtual machine first and configure the network as follows

We need to use dual network cards here. We turn on the second network card as shown below

Then start the virtual machine and perform the following operations

# Enter the directory where the network card is located cd /etc/sysconfig/network-scripts/
# Back up network card information cp -rp /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-enp0s3.bak
# Edit 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 the network card 1 we added. We will copy and modify it to 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="8.8.8.8"

Note:

UUID should be replaced with your own. You can use the uuidgen command to generate it. Note that IPADDR, NETMASK, and GATEWAY in enp0s8 are not random. Since our network card 2 is in bridge mode, that is, it is equivalent to connecting the virtual machine and the host to the same network environment, you need to check the configuration of the host. Use WIN+R, type cmd+Enter to open the dos command line, and enter ipconfig /all to view the network configuration in the host, as shown below

Look carefully, the network segment configured in network card 2 is consistent with the network segment on the host. Use xshell to connect to the ip in network card 2.

Summarize

The above is the method and precautions for setting static IP in VirtualBox6 and CentOS7. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • VirtualBox installs CentOS7 virtual machine and enhancement tools (picture and text)
  • VirtualBox installation enhancements in CentOS 7 (shared folders)
  • Talk about the installation of centos enhanced functions on virtualbox6

<<:  Installation and configuration of mysql 8.0.15 under Centos7

>>:  Vue.js implements music player

Recommend

How to pass W3C validation?

In addition to setting regulations for various ta...

In-depth understanding of Vue-cli4 routing configuration

Table of contents Preface - Vue Routing 1. The mo...

NULL and Empty String in Mysql

I recently came into contact with MySQL. Yesterda...

getdata table table data join mysql method

public function json_product_list($where, $order)...

Summary of MySQL development standards and usage skills

1. Naming conventions 1. Database names, table na...

Three examples of nodejs methods to obtain form data

Preface Nodejs is a server-side language. During ...

How to change the color of the entire row (tr) when the mouse stops in HTML

Use pure CSS to change the background color of a ...

503 service unavailable error solution explanation

1. When you open the web page, 503 service unavai...

Using JS to determine the existence of elements in an array in ten minutes

Preface In front-end development, you often need ...

Uniapp implements DingTalk scan code login sample code

Since Uniapp does not have DingTalk authorization...

Will Update in a Mysql transaction lock the table?

Two cases: 1. With index 2. Without index Prerequ...