Basic DNS and Domain Name System Architecture

Source: Internet
Author: User
Tags domain name server net domain subdomain name
Let's talk about csdn first.
Www.csdn.net

Primary Domain class
Host Name type
Name
Type: the type of the domain name (COM, net, org, Edu, Gov, etc)
Domain Name: Domain Name
Host Name: name of a host in the domain
Note:
① Indicates the WWW webpage server in the csdn.net domain
② It is case-sensitive and transparent, such as www. csdn. net.
③ The complete domain name actually has a "." at the end, that is, www.csdn.net., "." stands for the root DNS server.

The domain name is intended for users, while the bottom layer of the computer is still dependent on IP communication.



Daily hosts (Personal PCs, etc.) are generally used as DNS clients
The browser calls the gethostbyname () provided by the underlying OS to initiate a query on the DNS server.
Then implement domain name resolution

Domain name resolution Method


①/Etc/hosts
② DNS
③ NIS
Note:
⒈ Hosts files have a high priority. Generally, the OS preferentially accesses hosts.
For example:
[Root @ even ~] # Cat/etc/hosts
127.0.0.1 even.example.com even
117.79.93.222 www.csdn.net
However, this hosts file is often used by some hackers as a "phishing attack"
Resolve the IP address of the Agricultural Bank of China to another phishing network set by hackers
Without knowing it, your user name and password will be socket

The second-case DNS is used for resolv. conf.
[Root @ even ~] # Cat/etc/resolv. conf
; Generated by/sbin/dhclient-script
Search example.com # Domain Name of the Domain Name Server
Nameserver 192.168.227.2 # IP address of the Domain Name Server
On the client side, information about the DNS server is stored in the file/etc/resolv. conf.
When the client asks the server for a domain name, the server must answer the real IP address of the domain name.
The local DNS first queries its own data DNS server library. If your database does not exist, you will be asked by the DNS superior.
After obtaining the answer, save the received answer and answer the customer
The DNS server records the name information of the domain based on different zones. This information includes the subdomain name and Host Name of the domain.


However, we can change the query priority through/etc/nsswitch. conf.
[Root @ even ~] # Cat/etc/nsswitch. conf
Hosts: Files DNS
Files here refer to the/etc/hosts file.
If we want to change this order:
Or delete the keyword files.
Or drop files and DNS in order.

DNS-specific query command


① Simple: Host
-→ Host www.csdn.net
② Balanced type: Dig
-→ Dig www.csdn.net
Neither of the two will use the/etc/nsswitch. conf configuration.
DNS query is only performed through/etc/resolv. conf.


[root@even ~]# dig +trace www.csdn.net; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5 <<>> +trace www.csdn.net;; global options:  printcmd.                       371171  IN      NS      d.root-servers.net..                       371171  IN      NS      k.root-servers.net..                       371171  IN      NS      m.root-servers.net..                       371171  IN      NS      e.root-servers.net..                       371171  IN      NS      i.root-servers.net..                       371171  IN      NS      f.root-servers.net..                       371171  IN      NS      a.root-servers.net..                       371171  IN      NS      b.root-servers.net..                       371171  IN      NS      c.root-servers.net..                       371171  IN      NS      h.root-servers.net..                       371171  IN      NS      g.root-servers.net..                       371171  IN      NS      l.root-servers.net..                       371171  IN      NS      j.root-servers.net.;; Received 512 bytes from 192.168.1.1#53(192.168.1.1) in 87 msnet.                    172800  IN      NS      k.gtld-servers.net.net.                    172800  IN      NS      g.gtld-servers.net.net.                    172800  IN      NS      j.gtld-servers.net.net.                    172800  IN      NS      m.gtld-servers.net.net.                    172800  IN      NS      i.gtld-servers.net.net.                    172800  IN      NS      f.gtld-servers.net.net.                    172800  IN      NS      e.gtld-servers.net.net.                    172800  IN      NS      h.gtld-servers.net.net.                    172800  IN      NS      d.gtld-servers.net.net.                    172800  IN      NS      l.gtld-servers.net.net.                    172800  IN      NS      a.gtld-servers.net.net.                    172800  IN      NS      c.gtld-servers.net.net.                    172800  IN      NS      b.gtld-servers.net.;; Received 487 bytes from 128.8.10.90#53(d.root-servers.net) in 348 mscsdn.net.               172800  IN      NS      ns1.dnsv2.com.csdn.net.               172800  IN      NS      ns2.dnsv2.com.;; Received 171 bytes from 192.42.93.30#53(g.gtld-servers.net) in 236 mswww.csdn.net.           600     IN      A       117.79.93.222csdn.net.               600     IN      NS      ns1.dnsv2.com.csdn.net.               600     IN      NS      ns2.dnsv2.com.;; Received 100 bytes from 221.204.186.8#53(ns1.dnsv2.com) in 195 ms

Note:
① We can see from the above:
"." → "Net." → "csdn.net." → "www.csdn.net ."
② "Csdn.net." This Domain Name Server is usually maintained by the enterprise or rented by an individual carrier.
We can freely control the host information under this domain name.
We can build such a DNS server on our own.


DNS query type


① Recursive query


② Loop Query


③ Hybrid Query


Resource Record


On the DNS server, DNS information is saved in the resource record (RR, Resource Record) format.
Rr not only saves the ing information from the domain name to the IP address, but also saves a lot of other information
Common RR attributes:
● Name: domain name and host name, such as WWW and mail
● Class: The resource category, which is generally in, representing the internet.
● Type: resource type, which is common as follows:
Between In A → IPv4 address: used to set the corresponding record of the IP address of the Host Name
Routing in AAAA → IPv6 address
Mailbox in MX → mail record: used to provide the mail server name
Alias in cname → alias: Used to set an alias for the host name in the region File
Forward in PTR → pointer (reverse resolution): syntax (IP address in PTR host name)
Serving in SRV → service resources

Running in NS
● RDATA: Record Data
For example:
WWW in a 192.168.1.1

Name class type RDATA



DNS server type


MASTER: saves the zone configuration file for this domain. All configuration and changes of this domain are performed on this server.
SLAVE: captures the zone configuration file of the master, but has no permission to modify the zone configuration file. It can be used as a server Load balancer instance.
Cache: No Zone configuration file exists. It only relies on the cache to provide services for the client. It is usually used for load balancing and accelerated access. For example, a cache DNS server can be set up at the egress of a large LAN.
Visible, regardless of slave or cache, the zone configuration file of the master is cached.



Zone configuration file


On a DNS server, a domain stores information about the domain through a zone file.
The zone file format is standardized.


Note:
① The code above "ns @" does not need to be managed. There are standard modules for your reference.

▼ Serial: serial number. If the DNS configuration file is modified once, the serial number is incremented to notify the lower-level or slave server to refresh the configuration file because the serial number is inconsistent.
Refreshing Refresh: refresh time, 1D: One day, that is, refresh from the server once a day
Retry retry: How long will it take to retry if the refresh fails?
▼ Expire: how long will the cache information expire?
The preceding information is used to synchronize information between master and slave servers.
Generally, you can use the default value. You may only need to modify the value of serial.


Advanced Query


● Dig-t mx www.csdn.net
Case: query the mail server of Gmail

[root@even ~]# dig -t mx gmail.com; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5 <<>> -t mx gmail.com;; global options:  printcmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64810;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 4, ADDITIONAL: 8;; QUESTION SECTION:;gmail.com.                     IN      MX;; ANSWER SECTION:gmail.com.              949     IN      MX      10 alt1.gmail-smtp-in.l.google.com.gmail.com.              949     IN      MX      20 alt2.gmail-smtp-in.l.google.com.gmail.com.              949     IN      MX      30 alt3.gmail-smtp-in.l.google.com.gmail.com.              949     IN      MX      40 alt4.gmail-smtp-in.l.google.com.gmail.com.              949     IN      MX      5 gmail-smtp-in.l.google.com.;; AUTHORITY SECTION:gmail.com.              186940  IN      NS      ns2.google.com.gmail.com.              186940  IN      NS      ns3.google.com.gmail.com.              186940  IN      NS      ns1.google.com.gmail.com.              186940  IN      NS      ns4.google.com.;; ADDITIONAL SECTION:alt1.gmail-smtp-in.l.google.com. 244 IN AAAA    2a00:1450:4010:c04::1balt2.gmail-smtp-in.l.google.com. 244 IN AAAA    2607:f8b0:4002:c04::1aalt3.gmail-smtp-in.l.google.com. 244 IN AAAA    2607:f8b0:400d:c00::1balt4.gmail-smtp-in.l.google.com. 244 IN AAAA    2607:f8b0:400c:c02::1bns1.google.com.         184158  IN      A       216.239.32.10ns2.google.com.         189126  IN      A       216.239.34.10ns3.google.com.         186984  IN      A       216.239.36.10ns4.google.com.         192641  IN      A       216.239.38.10;; Query time: 28 msec;; SERVER: 192.168.1.1#53(192.168.1.1);; WHEN: Tue Nov 27 00:26:40 2012;; MSG SIZE  rcvd: 398

The number after MX indicates the priority.
● Dig-x reverse resolution
● Dig-t soa query information above "ns @" in the zone configuration file
Case: query the SOA information of the csdn.net domain

[root@even ~]# dig -t soa csdn.net; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5 <<>> -t soa csdn.net;; global options:  printcmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5007;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 6;; QUESTION SECTION:;csdn.net.                      IN      SOA;; ANSWER SECTION:csdn.net.               570     IN      SOA     ns1.dnsv2.com. level3dnsadmin.dnspod.com. 1353658206 3600 180 1209600 180;; AUTHORITY SECTION:csdn.net.               320     IN      NS      ns1.dnsv2.com.csdn.net.               320     IN      NS      ns2.dnsv2.com.;; ADDITIONAL SECTION:ns1.dnsv2.com.          14141   IN      A       122.225.217.193ns1.dnsv2.com.          14141   IN      A       183.60.59.230ns1.dnsv2.com.          14141   IN      A       221.204.186.8ns2.dnsv2.com.          14141   IN      A       180.153.162.151ns2.dnsv2.com.          14141   IN      A       112.90.143.34ns2.dnsv2.com.          14141   IN      A       119.167.195.7;; Query time: 27 msec;; SERVER: 192.168.1.1#53(192.168.1.1);; WHEN: Tue Nov 27 00:31:54 2012;; MSG SIZE  rcvd: 225

If you are debugging DNS connectivity, you can use the free global DNS free server provided by Google: 8.8.8.8

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.