Summary of solutions for Xshell not connecting to the virtual machine

One: About ping

1. Virtual machine ping Baidu

Ping Baidu in the virtual machine to see if it can be pinged first. If the virtual machine cannot connect to the network, Xshell will definitely not be able to connect.

Solution: Click Edit in the virtual machine -> Virtual Network Editor

Insert picture description here
Insert picture description here

From these two figures, we can see the corresponding values ​​of netmask and gateway, and then vi /etc/sysconfig/network-scripts/ifcfg-ens33(note that the last -ens33 may have a different network card, and some people's network card is eth0)

Then change wq to save in this file according to the following example

Insert picture description here

After saving it, run service network restart and restart the network.

2. Ping linux ip address under windows

After the above problem is solved, check whether the ip address of linux can be pinged under windows. If
ping fails, you can use the following methods to solve

Control Panel -> Network and Internet -> Network Connection

Insert picture description here

After selecting VM8, configure as follows. Note that the ip address configuration in the picture is like this. You can see a subnet IP in the lower right corner of the first picture of the blog. If our subnet IP is 192.168.10.0, fill in the IP address inside. 192.168.10.1, the subnet IP is 192.168.20.0, and the IP address inside is 192.168.20.1

Insert picture description here

At this point, after clicking OK, we will click on the disable of VM8. After clicking, disable and then right-click to enable. Then go to ping the host IP of Linux and it will work (although it is a bit of sb operation, but I tried It seems that this is the only way to do it, just like restarting. In fact, in many cases, ping can't work under Windows and Linux, we can first disable VM8 and then enable it to basically solve it )

Insert picture description here
Insert picture description here

3. linux under ping windows

Under normal circumstances, Linux can ping windows. If the ping fails, you can search for the reason. I will not describe it here.

Two: the problem of firewall

Two: Check whether the firewall in your virtual machine is turned off in
CentOs6.
View the firewall status: service iptables status
Turn off the firewall: service iptables stop
Disable the firewall: chkconfig iptables off


View firewall status in CentOs7 : systemctl status firewalld.service
Turn off the firewall: systemctl stop firewalld.service
Disable the firewall: systemctl disable firewalld.service

Three: ssh service

If the firewall is okay, check whether the ssh service is turned on.
Check the ssh status: service sshd status
Insert picture description here
is active under normal circumstances. If it shows dead, you need to manually start it (service sshd start). If you open an error saying that the ssh service is not installed, please first Move here

Four: restore default settings in the VM

If the above operations are okay, Xshell still cannot connect to our virtual machine, you can click Edit in the VM -> Virtual Network Editor-restore the default settings ( this method is actually more effective )

Insert picture description here

Note that after the restoration, we will mainly look at the VM8.
This is the NAT setting before restoration.

Insert picture description here

Did not restore the previous DHCP settings

Insert picture description here

Here I paste the subnet IP, gateway IP (gateway), start and end IP addresses of VM8 after restoring the default settings.

Insert picture description here

Insert picture description here

Insert picture description here

Change settings after restoration

Note:
1. When we have only a simple single virtual machine, then you can restore the default application to click the right settings, then click OK next, then we have vi /etc/sysconfig/network-scripts/ifcfg-ens33to change the IP address before starting after you restore the DHCP IP And end any one of the IP addresses, for example, I changed it to 192.168.58.130, and changed the gateway to the gateway IP in the NAT settings. If the subnet mask is changed, also change it. After the change, service network restart will restart the network. You can connect to the virtual machine.

2. When our virtual machine is a cluster composed of many Linux, it is more troublesome to use the above method of modifying the configuration file. You can modify the subnet IP and NAT settings of VM8 according to the information in the previous configuration file ifcfg-ens33 , The value in DHCP, note that in DHCP, only the data in the third example of its start IP and end IP needs to be modified, and the others have not changed from before. After modification, click Apply and confirm.

Five: Whether related services are open

Five: Click on this computer -> Management -> Services and Applications -> Services to
check whether the related services of the VM have been turned on. If they are not turned on, manually turn them on first. If they are turned on, the Xshell can not be connected. You can restart these services.

Insert picture description here

Six: uninstall VM software and reinstall

Six: It is possible that a small bug in the VMware Workstation software causes the Xshell to fail to connect. We can first shut down the previous virtual machine, uninstall VMware and reinstall it, which can also solve the problem.

Guess you like

Origin blog.csdn.net/weixin_44080445/article/details/110714332