How to view and modify DNS configuration in a Linux system

Source: Internet
Author: User
Tags domain name server nslookup nslookup command linux

DNS refers to the computer domain Name System, which consists of a domain name resolver and a domain name server, which provides DNS services to DNS servers. General operation of the domain name preferably has two or more DNS servers, respectively known as the primary domain name server and from the domain name server, where the second DNS server is often used for failover. Many users do not know how to view and modify DNS, so the small set next to you on the Linux system to view and modify the DNS configuration methods.

  To view DNS information for a server:

1: View/etc/resolv.con files

[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:

;; -"The 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 $} ' | Awk-f: ' {print $} '

192.168.xxx.xxx

4: Some other ways to view DNS information

There are other ways to see the DNS configuration information on the server, as shown below, but these methods, due to environmental restrictions, I have not verified, for reference only.

Nm-tool | grep DNS

NMCLI Dev list iface eth0 | grep IP4

  Modifying DNS information for a server

Modifying a DNS server is simple, and you only need to modify the/etc/resolv.conf configuration file. The answer is no if you need to restart some services to modify DNS. The changes will take effect immediately and do not require any additional processing.

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.