The DNS domain name system is a protocol that works at the application layer listening port: TCP53: When the secondary Domain Name Server transmits information to the Primary Domain Name Server, it uses TCP53 to communicate with the Master/Slave server UDP53DNS: provides a mutual conversion mechanism between domain names and IP addresses, in order to facilitate people's memory and management, the early DNS was implemented through the/hosts file shared by ftp. the design concept of/etc/hosts to achieve DNS retrieval is hierarchical and distributed, just like our country management
A dns domain name system is a protocol that works at the application layer.
Listening port: TCP 53: When the secondary Domain Name Server transmits information to the Primary Domain Name Server, TCP53 is used to communicate with the Master/Slave server.
UDP 53
The role of DNS: provides a mutual conversion mechanism between domain names and IP addresses. The mother's goal is to facilitate people's memory and management.
Early DNS was implemented through the/hosts file shared by ftp.
/Etc/hosts for retrieval
The DNS design concept is hierarchical and distributed. Just like our country management, DNS is an inverted tree structure in DNS. root Domain, only 13 root node servers around the world, 2. level 1 domain name (. com ,. org organization domain and National domain, Reverse Domain is more common. 3. A second-level domain is a subdomain owned by an organization. A maximum of 63 levels can be divided.
The subordinate domain is authorized by the upper-level domain, and the upper-level domain can manage the lower-level domain and access the lower-level domain, but the lower-level domain does not know the upper-level domain.
The DNS resolution process consists of two types: recursion and iteration. Recursion means that the DNS client only needs to send a request to the DNS server. The DNS server sends a request to the root domain, and the root domain queries the lower-level domain to return the request result to the DNS server. An iteration is a request from the DNS server to the root domain. The result returned by the root domain is the reference answer, which tells the DNS server to know which subdomain to query.
Resolution Sequence; 1 indicates whether the server is running; 2 indicates whether the DnS Cache exists; 3. Search for the hosts file; 4. Search for the DNS server.
Region type;
Hint root prompt
Master Domain Name Server
Slave Domain Name Server
Forward forwarding domain
Record type:
Subdomain: to let others know, let the superiors have your records
Start Authorization Record of SOA record (identify master Domain Name Server)
The NS record declares the Domain Name Server of this domain
A record host name to IP address (forward resolution)
Pir ip address to host name (reverse resolution)
MX record identification the mail server has a priority for the mail server in the same domain. The greater the value, the higher the priority.
CNAME alias
Only one SOA record can exist and must be placed at the beginning
Global TTL configuration items and SOA records
$ TTL (Time To Live) Record
SOA (Start Of Authority) Record
Comments starting with Semicolon ";"
Example:
$ TTL 86400; default cache time for valid address resolution records
@ In soa 6688. cc. (the address of the DNS region) admin.6688.cc. (the email address of the pipeline staff IN the DNS Region)
2009021901 the serial update serial number is used to mark changes to the address database. It can be an integer of less than 10 digits.
3 H refresh time: from the server to the master server, check whether the update interval is correct.
15 M retry time retry delay after the Domain Name Server fails to update the address database, how long will it take to try again?
1 W (1 week) expire time failure time contact the master server when the contact is 7 days or when the contact is not available, the slave server will be miserable! The role of the primary server in the form of a secondary server in the past seven days, from the primary server to the secondary server
1D negative answer ttl the cache time for the negative answer sets the default cache time for Invalid Address Resolution records (addresses that do not exist in the Database)
Cache Domain Name Server
This is also called a high-speed cache server.
Query other domain name servers to obtain domain name-> ip address records
Caches Domain name query results locally to speed up repeated queries
Primary Domain Name Server
The official server in a specific DNS region, which is unique
Maintains the ing records of all domain names> IP addresses in the region.
Slave Domain Name Server
It is also called a secondary Domain Name Server.
Its maintained Domain Name> ip address record comes from the Primary Domain Name Server
Regional transfer: synchronization between the master server and the secondary server
Full-region transfer: axfr must be completely transferred at the beginning
Incremental region transfer: full synchronization after ixfr
Tcp 53 master-slave server communication
When the master server makes a change, it will actively synchronize it to the slave server.
Domain name resolution record
NS Domain Name Server record
MX Mail Exchange records
The A Address record is only used in the region data file for forward resolution.
CNAME alias (Canonical Name) Record
Example:
@ In ns ns1.6688.cc.
In mx 10 mail.6688.cc.
Ns1 in a 192.168.0.181
Mail in a 192.168.0.181
Www in a 192.168.0.181
Ftp in cname www
Resolution type
Domain name --> forward IP resolution
IP --> Reverse Domain name resolution
A forward or reverse parsing file makes up a region
Region: Physical Concept
Domain: logical concept
Domain can be divided into subdomains, forward resolution, reverse resolution,
Forward and reverse resolution are also available in subdomains.
For each forward parsing, reverse parsing requires a parsing database.
Each DNS database corresponds to a region.
BIND Introduction
In Linux, Domain Name Service (DNS) is implemented by Berkeley Internet Name Domain-BIND.
BIND is a customer/service system. Its customer side is called a resolver. It generates domain name information queries and sends such information to the server, the DNS software answers the query of the Conversion Program. The service of BIND is a daemon called named.
BIND (Berkeley Internet Name Daemon)
Berkeley Internet Domain Name Service
Site: https://www.isc.org/
Related Software Packages
Bind-9.3.3-7.el5.i386.rpm
Caching-nameserver-9.3.3-7.el5.i386.rpm
Provide necessary default configuration files for configuring BIND as the cache Domain Name Server
You can make a slight modification in the configuration file so that it can be used as the master server.
BIND server program
Main execution program:/usr/sbin/named
Service Script:/etc/init. d/named
Default listening port: 53
Main configuration file:
/Etc/named. conf
The data file that saves the DNS resolution record is located:
/Var/named/
Install DNS
Configure the BIND server
Edit the "/etc/named. conf" File
Create and edit the forward zone resolution file in the/var/named/directory
Create and edit the reverse region resolution file in the/var/named/directory
Edit the "/etc/resolv. conf" file of the Client
Start the BIND server
Configure and test the client
Make sure that the IP address to be configured to the DNS server is statically allocated and has IP connectivity with the client.
Smart resolution: a host name corresponds to two IP addresses called Server Load balancer.
Www.linuxidc.com www.linuxidc.net
CDN: pushes the data to be accessed by the user to the home of the user
The following describes how to manually perform DNS
Master DNS Server
1. rndc-confgen>/etc/rndc. conf
Cat! $
Set key "rndckey "{
Algorithm hmac-md5;
Secret "uAgAJYS + FB3xvAWoVxctGQ = ";
};
Controls {
Inet 127.0.0.1 port 953
Allow {127.0.0.1;} keys {"rndckey ";};
};
Copy to the/etc/named. conf configuration file
Vim/etc/named. conf
Compile options {
Directory "/var/named ";
Querylog yes; Start log
Version "hh ";
};
Zone "." IN {
Type hint;
File "named. ca ";
};
Zone "localhost" IN {
Type master;
File "localhost. zone ";
};
Zone "0.0.127.in-addr. arpa" IN {
Type master;
File "named. local ";
};
Save and exit.
Chmod o-r/etc/named. confd needs to change its permissions to other users without any permissions.
Change chgrp named/etc/named. conf to named
Cd/var/named/
Compile the region file named. ca localhost. zone named. local.
Dig-t NS.>/var/named. ca get all records
Compile the localhost. zone region File
Vim localhost. zone
$ TTL 43200
@ In soa localhost. root. localhost .(
2011112401
3 H
15 M
1 W
1D)
In ns localhost.
Localhost. in a 127.0.0.1
Cp localhost. zone named. local
Modify named. local
Vim named. local
$ TTL 43200
@ In soa localhost. root. localhost .(
2011112401
3 H
15 M
1 W
1D)
In ns localhost.
1 in ptr localhost.
Chown: named localhost. zone named .*
Named-checkconf check master configuration file
Named-checkzone check area file
Named-checkzone "localhost" localhost. zone
Service named start service
Tail/var/log/messages. Check the log to see if any error exists.
Vim/etc/named. conf
Edit forward and reverse resolution
Zone "6688.cc" IN {
Type master;
Files "6688. cc. zone ";
};
Zone "0.168.192.in-addr. arpa" IN {
Type master;
File 192.168.0.local ";
};
Cd/var/named
Vim 6688. cc. zone
$ TTl 600
$ ORIGIN 6688. cc.
@ In soa nsl.6688.cc. admin.6688.cc .(
2011112401
1 H
10 M
7D
1D)
In ns nsl
In ns NS2.
In mx 10 mail
In mx 20 mail2
Ns1 in a 192.168.0.181
Ns2-in A 192.168.0.182
Mail in a 192.168.0.181
Mail2 in a 192.168.0.182
Www in a 192.168.0.181
Ftp in a 192.168.0.181
Www2 in cname www
Cp 6688. cc. zone 192.168.0.local
Vim 192.168.0.local modification content
$ TTl 600
$ ORIGIN 6688. cc.
@ In soa nsl.6688.cc. admin.6688.cc .(
2011112401
1 H
10 M
7D
1D)
In ns nsl
In ns NS2.
In mx 10 mail
In mx 20 mail2
181 in ptr ns1
182 in ptr NS2.
181 in ptr mail
182 in ptr mail2
181 in ptr www
181 in ptr ftp
Chmod o-r 6688. cc. zone 192.168.0.local
Chgrp nameed 6688. cc. zone 192.168.0.local
Named-checkconf check master configuration file
Named-checkzone check area file
Service named restart
Tail/var/log/messages
Disable selinux
Setenforce 0
Rndc is a dns Remote Configuration Tool
Rndc flush clear linux dns Cache
Rndc status view DNS Region
Rndc reload re-read configuration file
Rndc trace 2 debug the second process
Rndc stop Service
Rndc notrace stops debugging
Rndc freeze zone prevents a region from working
Retransfer re-transmits a region
Configure slave server
Same as creating a master server
Rndc-confgen>/etc/rndc. conf
Cat! $
Set key "rndckey "{
Algorithm hmac-md5;
Secret "uAgAJYS + FB3xvAWoVxctGQ = ";
};
Controls {
Inet 127.0.0.1 port 953
Allow {127.0.0.1;} keys {"rndckey ";};
};
Copy to the/etc/named. conf configuration file
Vim/etc/named. conf
Compile options {
Directory "/var/named ";
Querylog yes; Start log
Version "hh ";
};
Zone "." IN {
Type hint;
File "named. ca ";
};
Zone "localhost" IN {
Type master;
File "localhost. zone ";
};
Zone "0.0.127.in-addr. arpa" IN {
Type master;
File "named. local ";
};
Save and exit.
Chmod o-r/etc/named. confd needs to change its permissions to other users without any permissions.
Change chgrp named/etc/named. conf to named
Cd/var/named/
Compile the region file named. ca localhost. zone named. local.
Dig-t NS.>/var/named. ca get all records
Compile the localhost. zone region File
Vim localhost. zone
$ TTL 43200
@ In soa localhost. root. localhost .(
2011112401
3 H
15 M
1 W
1D)
In ns localhost.
Localhost. in a 127.0.0.1
Cp localhost. zone named. local
Modify named. local
Vim named. local
$ TTL 43200
@ In soa localhost. root. localhost .(
2011112401
3 H
15 M
1 W
1D)
In ns localhost.
1 in ptr localhost.
Chown: named localhost. zone named .*
Named-checkconf check master configuration file
Named-checkzone check area file
Named-checkzone "localhost" localhost. zone
Service named start service
Tail/var/log/messages. Check the log to see if any error exists.
Dig-t axfr 6688.cc
Vim/etc/named. conf
Zone "6688.cc" IN {
Type slaves;
File "slaves/6688. cc. zone ";
Masters {192.168.0.181 ;};
};
Service named restart
Tail/var/log/messages
Disable selinux
Setenforce 0
Test: cd/var/named/slaves
Cat 6688. cc. zone
Check whether there is a forward resolution of the master server. If yes, it will succeed. Then, modify the forward resolution region file of the master server to see if the file can be synchronized.
Subdomain authorization:
Add NS records and A records to the forward resolution configuration file of the parent domain
Several NS servers need to write several NS records and corresponding A records.
If you want to resolve a subdomain, you can resolve the parent domain again.
Add
Forward:
Zone "gagedu.com" IN {
Type forward;
Forwarders {192.168.0.181 ;};
Forward only | first;
};
Forward only recursive forwarding
Forward first shows recursion and then uses Iteration
You can also use forward globally to allow the host to access the domain it knows by forwarding the host.
Options {
Forward only | first;
Forwarders {IP ;};
}
Restrictions must be imposed to achieve secure region Transfer
Allow-transfer {192.168.0.1}
Allow-transfer {none ;}
To use an Acl in DNS, you must first define the acl before using it.
Acl "name "{
Host list;
};
Write allow-transfer {name;}; in the region to be limited; transfer allowed
Allow-query {name;}; who can query
Use allow-recursion {none;} in the global environment. recursion is not allowed.
Intelligent DNS:
Returns a set resolution result for a resolution request based on the client's source IP address.
Multiple regions can be defined in each view.
As long as we use the view, every region must be in the view.
Match the client request source with the keyword match-clients
View-name {
Match-clients {191.168.0.0/24 ;};
Zone
};
It's a mess. You should point out the shortcomings or errors.