Set static IP for CentOS in VMware

Because the previously built MongoDB shard did not use a replica set, the current network has been under pressure recently, so I am going to study it, so I set up the environment in my computer's virtual machine, but I found that VMware set up DHCP before, so The IP in the virtual machine changes every time after restarting, causing the mongodb environment that has been built before to always have problems and it is troublesome to rebuild, so the steps to set a static static IP are very simple:

First turn off VMware's DHCP:

Edit->Virtual Network Editor

Select VMnet8 and remove the Use local DHCP service to distribute IP address to VMs option. Click NAT Settings to check the GATEWAY address:

Just click OK.

Set CentOS static IP:

Three configuration files are involved, namely:

/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf

First modify /etc/sysconfig/network as follows:

NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.129.2

Specify the gateway address.

Then modify /etc/sysconfig/network-scripts/ifcfg-eth0:

DEVICE="eth0"
# BOOTPROTO="dhcp"
BOOTPROTO="static"
IPADDR=192.168.129.129
NETMASK=255.255.255.0
HWADDR="00:0C:29:56:8F:AD"
IPV6INIT="no"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="ba48a4c0-f33d-4e05-98bd-248b01691c20"
DNS1=192.168.129.2

Note: DNS1 must be set here, otherwise [Domain Name Resolution] (https://cloud.tencent.com/product/cns?from=10680) cannot be performed.

Finally, configure /etc/resolv.conf:

nameserver 192.168.129.2

In fact, this step can be omitted. After the DNS Server address is set above, the system will automatically modify this configuration file.

After a few simple steps, the IP of the virtual machine is always 192.168.129.129.

Recommended Posts

Set static IP for CentOS in VMware
Set static IP under Centos
How to set static IP in ubuntu14.04
Ubuntu18.04, Centos7 static IP
ubuntu16.04 set static ip
Summary of CentOS method to set static IP
ubuntu 18.04 set static ip method
Configure static IP under CentOS 7
Use NTP for time synchronization in CentOS 7
Set UTF-8 encoding for MySQL5.7 in Ubuntu 16.04
How to set static IP on Ubuntu 18.04 Server
How to set static IP on Ubuntu 18.04 Server
Vmware install CentOS6
Explain how to set static IP on ubuntu14.04
ubuntu20.04 set static ip address (including different versions)
[Quick Start with Ubuntu] Two, Ubuntu set static IP
Installation and configuration of CentOS 7 in VMware Workstation
Explain the implementation of Centos8 static IP configuration
IP and network settings of CentOS Linux 7 VMware
How to create a CentOS virtual machine in VMware
How to create a CentOS virtual machine in VMware
Detailed explanation of CentOS7 network setting tutorial in vmware
ubuntu 17.10 set solid IP
Install MySQL5.7 in centos7
Install php in centos
Install CentOS under VMware
Install redis5.0 in CentOS7
Build Hadoop in CentOS
Centos7 configure IP address
KVM virtualization in centos
How to set or modify the time zone in CentOS 8