Configure CentOS static IP in VMware

Source: Internet
Author: User
Tags mongodb sharding
We often take it for granted that the gateway and dns are the same as the host machine, and the configuration results are unavailable for a long time. Actually not... In VMware, CentOS sets up static IP addresses because replica sets are not used for MongoDB sharding. recently, the current network is under a lot of pressure, so we are going to study it. so we set up an environment in a virtual machine on our computer, however, it was found that VMware had previously set DHCP, so the IP address in the VM changed every time it resume again, resulting in the previously set-up mong

We often take it for granted that the gateway and dns are the same as the host machine, and the configuration results are unavailable for a long time. Actually not...

Set static IP addresses for CentOS in VMware

Because the replica set is not used for MongoDB fragments, and the current network is under a lot of pressure recently, so I want to study it. so I will build an environment in my own computer's virtual machine, however, it was found that VMware had previously set up DHCP, so the IP address in the virtual machine had changed every time after resume, which made it very difficult to re-build the mongodb environment that had already been set up, to set a static IP address, follow these steps:

First, disable VMware 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 view the GATEWAY address:

Click OK.

Set CentOS static IP address:

Three configuration files are involved:

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

First, modify/etc/sysconfig/network as follows:

NETWORKING=yesHOSTNAME=localhost.localdomainGATEWAY=192.168.129.2

Specify the Gateway address.

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

DEVICE="eth0"#BOOTPROTO="dhcp"BOOTPROTO="static"IPADDR=192.168.129.129NETMASK=255.255.255.0HWADDR="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. otherwise, domain name resolution 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 steps, the IP address of the VM is 192.168.129.129.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.