How to modify the network card DNS in Linux system?

  
                

After the Linux system is reinstalled, the domain name cannot be resolved due to various reasons, so you need to modify the DNS. This article introduces from the temporary modification and permanent modification. Interested friends may wish to learn it.

There are two ways to modify DNS in Linux, temporary modification and permanent modification.

1. Temporarily modify the NIC DNS address

The code is as follows:

sudo vim /etc/resolv.conf

Change to the following content:

The code is as follows:

nameserver 8.8.8.8 #modified into your primary DNS

nameserver 8.8.4.4 #modified into your alternate DNS

search localhost #你The domain name

I used Google's DNS resolution server here. After the modification: wq exits, the configuration will take effect in real time, but the configuration may be lost after restarting the system. In fact, when editing this file, you should also be able to see the file header "Do not manually edit the comments".

2, permanent changes card DNS

code is as follows:

sudo & ndash; i

cd /etc/resolvconf/resolv.conf. d

vim base

Add the following content

The code is as follows:

nameserver 8.8.8.8

nameserver 8.8.4.4

:wq Save and exit, so the settings will not be lost after reboot.

In fact, your cat head file will find the comment in the header of the picture. It is not difficult to speculate that the resolv.conf file is based on the /etc/resolvcon f/re sol v.conf.d directory. Generated files.

The above is the way to modify the DNS under Linux. If you forgot to enter the DNS Server when you reinstall the system in Linux, try the method described in this article to modify the DNS address of the network card.

Copyright © Windows knowledge All Rights Reserved