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
Nameserver 192.168.xxx.xxx
# Search localdomain
[Root @ localhost ~] #

2: Use the nslookup command to view DNS information

[Root @ localhost ~] # Nslookup 127.0.0.1 | grep Server
Server: 192.168.xxx.xxx
[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 m.root-servers.net.
. 86163 in ns a.root-servers.net.
. 86163 in ns j.root-servers.net.
. 86163 in ns l.root-servers.net.
. 86163 in ns e.root-servers.net.
. 86163 in ns d.root-servers.net.
. 86163 in ns k.root-servers.net.
. 86163 in ns f.root-servers.net.
. 86163 in ns h.root-servers.net.
. 86163 in ns c.root-servers.net.
. 86163 in ns g.root-servers.net.
. 86163 in ns B .root-servers.net.
. 86163 in ns I .root-servers.net.
 
; Additional section:
A.root-servers.net. 3599 in a 112.4.20.71
B .root-servers.net. 86163 IN A 192.228.79.201
I .root-servers.net. 86173 IN A 192.36.148.17
 
; Query time: 8 msec
; SERVER: 192.168.xxx.xxx #53 (192.168.xxx.xxx)
; 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 }'
192.168.xxx.xxx

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:

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: info-contact@alibabacloud.com 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.