The virtual machine is configured as a static IP to ensure that the virtual machine's IP remains intact each time the host machine restarts, which is useful for learning about software in a clustered environment, such as a Hadoop cluster, a DB cluster such as MySQL.
After the VMware workstation has loaded the Linux system (here with CentOS 7), the virtual machine uses NAT to surf the internet and can be configured in a simple network configuration as follows:
1: Set the host name of the virtual machine hostname;
$ sudo hostnamectl set-hostname master_machine
(CentOS 7 uses the HOSTNAMECTL command to host name-related settings)
2: Set static IP
1> View the gateway for VMware:
2> configuration network;
$ cd/etc/sysconfig/network-scripts
$ ls
Modify the contents of a file
$ sudo vi ifcfg-eno16777736
The following changes are included:
Note that the Bootproto is changed from DHCP to static, plus IPADDR (the static IP you want to specify) NETMASK (subnet mask 255.255.255.0) Gateway (the gateway IP seen in the first step of VMware) DNS1 (114.114.114.114).
3> reboot under:
$ sudo service network restart
This completes the static IP setting.
Sometimes we want to use host name to access between the local area network of the virtual machine, then modify the/etc/hosts file, for example:
Configuring CentOS 7 static IP in VMware