How to view and modify DNS configurations in Linux

Source: Internet
Author: User
Tags nslookup nslookup command

How to view and modify DNS configurations in Linux

DNS server Introduction

DNS is the abbreviation of a computer Domain Name System (Domain Name System or Domain Name Service). It is composed of a Domain Name parser and a Domain Name Server. A Domain Name Server is a server that stores the domain names and corresponding IP addresses of all hosts in the network and converts a domain name to an IP address. The domain name must correspond to one IP address, and one IP Address can have multiple domain names, but the IP address may not necessarily have a domain name. The domain name system adopts a hierarchical structure similar to the directory tree. The Domain Name Server is usually the server in the Client/Server mode. It has two forms: the master server and the forwarding server. The process of ing a domain name into an IP address is called "domain name resolution ". The DNS server provides the DNS service. There are three types of DNS servers: Cache-only server, Primary Name server, and Second Name Server ).

In general, it is best to have two or more DNS servers for the domain name in operation. One is called the Primary Domain Name Server, and the other is called the slave Domain Name Server. The second DNS server is usually used for failover: If one server goes down, the other server is activated as a DNS server.

View DNS information of the server

In Linux, how does one view the configured DNS server information? There are generally the following methods:

1: view the/etc/resolv. con File

[Root @ localhost ~] # Cat/etc/resolv. conf
# Search localdomain
[Root @ localhost ~] #

2: Use the nslookup command to view DNS information

[Root @ localhost ~] # Nslookup | grep Server
[Root @ localhost ~] #

3: Use the dig command to view DNS information

Root @ localhost ~] # Dig
; <> DiG 9.3.6-P1-RedHat-9.3.6-16.P1.el5 <>
; Global options: printcmd
; Got answer:
;-> HEADER <-opcode: QUERY, status: NOERROR, id: 36888
; Flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 3
; Question section:
;. IN NS
; Answer section:
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns
. 86163 in ns B
. 86163 in ns I
; Additional section: 3599 in a
B 86163 IN A
I 86173 IN A
; Query time: 8 msec
; SERVER: #53 (
; WHEN: Sat Apr 16 07:34:37 2016
; Msg size rcvd: 289
[Root @ localhost ~] # Dig | grep SERVER: | awk-F # '{print $1}' | awk-F: '{print $2 }'

4: Other methods to view DNS information

Some other methods are available on the Internet to view the DNS configuration information of the server, as shown below. However, due to environment restrictions, I have not verified these methods for your reference only.

Nm-tool | grep DNS
Nmcli dev list iface eth0 | grep IP4

Modify DNS information of a server

It is very easy to modify the DNS server. You only need to modify the/etc/resolv. conf configuration file. If you want to modify the DNS to restart some services, the answer is no. The modification takes effect immediately without any additional processing.

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.