Get the App
SLTechnology News&Howtos  ›  Servers  › 

How linux modifies dns

Shulou Source: shulou.com Published: 2022-05-31 11:20:52 09月21日 Update

This article mainly introduces the relevant knowledge of how linux modifies dns, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this linux article on how to modify dns. Let's take a look at it.

Methods: 1. Use the "vi / etc/resolv.conf" command to modify the dns;2, use the "vi / etc/sysconfig/network-scripts/ifcfg-eth0" command to modify the dns items in the file, and restart the network card to take effect after modification.

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How does linux modify dns

Method 1. Modify / etc/resolv.conf (recommended)

[root@bin ~] # vi / etc/resolv.confnameserver 8.8.8.8nameserver 8.8.4.4

The modification will take effect immediately without any additional processing! Therefore, this method is recommended.

Method 2. Modify / etc/sysconfig/network-scripts/ifcfg-eth0 file

[root@bin ~] # vi / etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0ONBOOT=yesBOOTPROTO=dhcpDNS2=8.8.4.4TYPE=EthernetDNS1=8.8.8.8IPV6INIT=noUSERCTL=noPEERDNS=yes

This method will not take effect until the Nic is restarted. You can restart the Nic with the following command:

Service network restart

How to check the native DNS

1. View / etc/resolv.con file

[oboth@localhost ~] $cat / etc/resolv.conf nameserver 114.114.114.114nameserver 8.8.8.8

2. Use the nslookup command to view DNS information

[oboth@localhost ~] $nslookup qq.comServer: 114.114.114.114Address: 114.114.114.114#53Name: qq.comAddress: 123.151.137.18Name: qq.comAddress: 61.129.7.47Name: qq.comAddress: 183.3.226.35

3. Use the dig command to view DNS information

[oboth@localhost] $dig; DiG 9.11.25-RedHat-9.11.25-2.fc33;; global options: + cmd;; Got answer:;;-> > HEADER

Tags: Commands contents files methods knowledge network cards information methods articles recommendations value easy to operate tutorials articles easy to understand more this method environment for computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB OPPO Reno vpn MySQL