Failed to connect to the host name but can connect to the host ip, can use the ip address to connect but cannot use the host name to connect, look here to solve it in one stop

Brief description of the problem

I used robo3t to configure the mongodb of centos and found that the connection failed, but I succeeded by changing all the addresses to ip. After searching for a long time, I found that the solution on the Internet is not very complete. Here I will make a detailed tutorial.

Solutions

I remember that garbled characters appeared when secureCRT used tree naming to view the folder path , so I used alias tree='tree --charset ASCII', that is, when entering tree, the system defaults that you enter tree --charset ASCII, which is similar to shortcut commands or translation The role of the dictionary

Therefore, this time, the ping host name can use translation to ping the host ip.

There are two translation places, one is the windows host, and the other is the virtual machine centos6.9 that needs to be set

Specific setting steps

1. Windows host settings

Computer open path: C:\Windows\System32\drivers\etc
insert image description here

The hosts file is a system file without modification permission, so you need to open the modification permission

Right-click hosts properties => general , do not check the read-only below

insert image description here

In Properties => Security => Advanced

insert image description here
insert image description here

Click Change, then enter your own system hostname in the input box and click Check Name

insert image description here

Then click OK all the time,
go back to this page and click Add
insert image description here

Click to select subject

****Bold Style****

Also enter the system hostname, click Check Name, and click OK

insert image description here
Then check all the basic permissions to open

insert image description here

After clicking OK, edit the hosts file

insert image description here

I write the ip address and its corresponding host name in the first line here

Save ok, the host's ip translation is ok

The following operates in the linux system
and enters: sudo vim /etc/hosts

insert image description here
If sudo is invalid, log in as root user, or read my previous blog and click here to jump

The last line is the ip and the corresponding host name
After adding, press the Esc key and enter: wq to save and exit the file

ok, now there is no problem in pinging the host name in cnetos black box and windows .

I think it's good, follow and bookmark , I will continue to update the bug solutions in the process of deployment and development of the recommendation system.

Guess you like

Origin blog.csdn.net/weixin_43419816/article/details/127497483