CentOS uses Yum install to report errors

I’m running the install tree command on the machine and there is an error:

[Errno 256] No more mirrors to try

The Internet says you should follow the following two commands:
#yum clean all
#yum makecache
There was no error on the first instruction, but there was an error on the second instruction
Cannot find a valid baseurl for repo: base/7/x86_64
So the solution is to change the nameserver value by changing the resolv.conf
Unable to connect to the Internet. This is one of the host errors
#vim /etc/resolv.conf
Change the nameserver value to 8.8.8.8 or any other DNS value that can connect to the Internet
Then restart the network card
#service network restart
Problem solved!

Read More: