Modify the Linux VPS host DNS address to solve the problem of being unable to remotely wget files

888u

Last update at :2024-06-29,Edit by888u

There should be many netizens who are like snails. For example, after opening a VPS, they will be very accustomed to directly installing the required environment (usually this is the case), but maybe because we need the address of the script data source downloaded by wget, we cannot Ensure that the network directly reaching the Linux VPS host server is smooth and stable. This will cause incomplete installation and incomplete download of some files when we install the deployment environment.

Generally, we only need to modify the DNS of the VPS host to solve this problem. For example, directly modifying the DNS in the /etc/resolv.conf file of the current VPS host to 8.8.8.8 and 8.8.4.4 can solve the problem. But we must have also found that the problem can be solved after we modify the DNS, but after restarting the VPS, the DNS returns to its original state and has not been completely changed.

So, in this article, Snail will record the process of temporarily and permanently changing the DNS when we modify the VPS host DNS. Generally, I also use the temporary modification method when I use it, but in order to ensure There is no need to worry about replacement in the future, and permanent replacement is also available.

First, temporarily modify the current DNS

vi /etc/resolv.conf

Then modify the default files as shown below.

After the modification is completed, then:wq save and exit, and then execute the script installation we need without much problem. For example, when installing some environment packages on Alibaba Cloud and Linode, it is impossible to install them without modifying the DNS.

Second, permanent modification of DNS method

Using the above method, if we restart the VPS, it will be the original default DNS again. If we need to permanently modify the DNS, how should we do it? Here, Snail takes the CentOS system for testing.

1. centos

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Add in the last two lines:

DNS1=8.8.8.8DNS2=8.8.4.4

After modifying, saving and exiting, when we restart the VPS, we will see that the DNS in the /etc/resolv.conf file is the fixed DNS we set.

2. debian

Most of the methods on the Internet are still based on CentOS. Here, Snail has sorted out the methods of Debian distribution version.

vi /etc/dhcp/dhclient.conf

Then add in the last line of dhclient.conf

prepend domain-name-servers 8.8.8.8, 8.8.4.4;

Then we save and exit.

In summary, through the above method, we can modify the DNS temporarily or permanently as needed. Snail friends no longer have to worry about the connection failure during wget.

Recommended site searches: website registration information, registered domain names, website registration, IP query network, registration-free space, US multi-IP station group vps, free virtual space, asp host space station group server, foreign virtual host, < /p>

Modify the Linux VPS host DNS address to solve the problem of being unable to remotely wget files

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码