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

VMware + Ubuntu18.04 Graphic Tutorial on Building Hadoop Cluster Environment

Table of contents Preface VMware clone virtual ma...

How to use mysqladmin to get the current TPS and QPS of a MySQL instance

mysqladmin is an official mysql client program th...

An example of implementing a simple finger click animation with CSS3 Animation

This article mainly introduces an example of impl...

Simple steps to implement H5 WeChat public account authorization

Preface Yesterday, there was a project that requi...

How to connect Django 2.2 to MySQL database

1. The error information reported when running th...

Docker implements cross-host container communication based on macvlan

Find two test machines: [root@docker1 centos_zabb...

Related operations of adding and deleting indexes in mysql

Table of contents 1. The role of index 2. Creatin...

Detailed explanation of several ways to create objects and object methods in js

This article is the second article about objects ...

How to use async await elegantly in JS

Table of contents jQuery's $.ajax The beginni...

Real-time refresh of long connection on Vue+WebSocket page

Recently, the Vue project needs to refresh the da...

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

Install CentOS 7 after installing VirtualBox. I w...

Docker-compose image release process analysis of springboot project

Introduction The Docker-Compose project is an off...

Graphic tutorial for installing MySQL 5.6.35 on Windows 10 64-bit

1. Download MySQL Community Server 5.6.35 Downloa...