1. Solving the problem that the virtual machine cannot connect to the network and cannot ping successfully

1 Introduction

Today, when I was operating Jedis to connect to the redis database of the virtual machine, I couldn't connect. I found many solutions but couldn't solve it. Finally, I found that it was a configuration problem of the virtual machine. The virtual machine could not connect to the network and the local IP address was not set, so ifconfig The IP address cannot be found at all, and Jedis cannot connect at all. Here is a summary of the solution:

2. Steps

First, log in with the root user and enter /etc/sysconfig/network-scripts. There is a ifcfg-ens33file like this. Different users may have different files, but they all use it to modify the IP address.

3. Modify configuration

Note:
IPADDR here refers to the local IP.
GATEWAY refers to the gateway. Note: the gateway here must be consistent with the gateway in step 4 to access the external network.
NETMARK refers to the network mask.
Insert image description here

4. Step 4

Enter the virtual network editor and check the network configuration. The NAT mode of my host is configured. The configuration here is different in different modes.
Insert image description here

5. Check the "Adapter" option of your win10
Insert image description here

Insert image description here

Supplementary information screenshot:

Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/qq_41787812/article/details/133078860