instructions
1, the notebook host IP is automatically obtained for setting, no matter what circumstances, not affected by the VIRTUAL machine, as long as the Internet can be connected to the normal Internet;
2. As long as the laptop host can access the Internet, start CentOS 7 on the VM to access the Internet without any configuration.
3. Set the VM to a fixed IP address. No matter what network environment the host is in, whether it is disconnected from the network or connected to any network segment to access the Internet, the VM IP address is fixed and remains unchanged.
4. The FIXED IP address of the VM can be set based on the desired IP address segment. For example, I want to set the fixed IP address to 192.168.2.2.
As for the above four points, I did not find a post on the Internet that could achieve the effect I required. After my research and various attempts during this period, various problems occurred during the test and stability, I summarized as follows to share with you, hoping to help you and avoid detachments.
The NAT mode and fixed IP address mode are adopted.
The configuration environment is as follows: The host is Win10 Home Edition, the vM is VMware Workstation 12 Pro Chinese version, and the Linux OPERATING system of the VM is CentOS 7 64-bit.
1. Set the vm network connection mode
2. Configure IP address parameters for the NAT mode
(1) Select VMnet8– deselect use local DHCP– set subnet IP– set gateway IP (remember this setting, it will be used later), as shown below
If you want to set the fixed IP address to 192.168.2.2-255, for example, 192.168.2.2, the subnet IP address is 192.168.2.0.
If you want to set the fixed IP address to 192.168.1.2-255, for example, 192.168.1.2, the subnet IP address is 192.168.1.0.
(2) The gateway IP address can be changed in the following format: 192.168.2.1
3. Set the local ADDRESS parameters of the notebook host VMnet8
Note: The IP address in Step 6 is optional, but make sure it is not the same as the fixed IP address you want to set for the VM
Modify CentOS on the VM. 7 Use the fixed IP address configuration file
#cd /etc/sysconfig/network-scripts/
#vi ifcfg-ens33
Modify/etc/sysconfig/network
# Created by Anaconda NETWORKING=yes GATEWAY=192.168.1.1
Then restart the service
service network restart
HWADDR must be added to the default network-scripts file
The final modification
1 BOOTPROTO=staticDHCP static boot protocol2 ONBOOT=Yes # The system will enable this interface at startup3 DNS1=114.114.114.114# the DNS configuration4 IPADDR=192.168.2.2# static IP5 NETMASK=255.255.255.0# Subnet mask6 GATEWAY=192.168.2.1# default gateway7 HWADDR=00:0c:29:3b:ae:c8 #MAC8NM_CONTROLLED=no # indicates that the interface will be set up through the profile and not managed through the network manager
After restarting the network service, it is ok, but after restarting the system, it still becomes dynamic
1 systemctl disable NetworkManager.service
2 chkconfig network on
3 systemctl stop NetworkManager
4 systemctl restart network
Verify whether the configuration is successful
Test Centos7
2. Test Window10
6. Remote terminal connection
(1) If the connection fails because the firewall port of CentOS 7 is not enabled, for example, port 80,3306 is enabled, the firewall must be restarted.
Check the firewall status
Copy the code
systemctl status firewalld
# Enable port 80
Copy the code
firewall-cmd --zone=public --add-port=80/tcp --permanent
Enable port 3306
Copy the code
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# restart firewall:
Copy the code
firewall-cmd --reload
Copy the code
Seven, test success
Viii. Reference materials
1.Hongda ‘s blog,www.cnblogs.com/hongdada/p/…
2, Linux, www.cnblogs.com/hongdada/p/…