Linux: DNS server setup
Link: https://www.cnblogs.com/yanlzy/p/11918018.html
Introduction to DNS
DNS (Domain Name System):
A system that uses a client/server mechanism to convert computer names to IP addresses. As an important network service, DNS is not only the basis for the work of the international Internet, but is also widely used in corporate internal networks.
DNS server Role
Forward resolution: Find the corresponding IP address based on the host name (domain name)
Reverse resolution: Find the corresponding
host domain name
based on the IP address
Distributed data structure of the DNS system
DNS query method
Recursive query: The way most clients resolve domain names to DNS servers
Iterative query: The way most DNS servers resolve domain names to other DNS servers
Types of DNS servers
Caching DNS
Cache domain name server: also known as a high-speed cache server, it obtains domain name->IP address records by querying other domain name servers, caches the domain name query results locally, and improves the speed of repeated queries.
Primary DNS Server
Primary domain name server: The official server of a specific DNS zone is unique and is responsible for maintaining the mapping records of all domain names -> IP addresses in the zone.
From the domain name server
Slave DNS server: Also called secondary DNS server, the domain name->IP address records it maintains are derived from the primary DNS server.
BIND Domain Name Service Basics
BIND (Berkeley Internet Name Daemon) Berkeley Internet Domain Name Service.
Official website: https://www.isc.org/
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 DNS resolution records is located in: /var/named/chroot/var/named/
Configuration file analysis
/etc/named.conf
options { #Options
listen- on port 53 { 127.0 . 0.1 ; }; #Service listening port is 53
listen- on -v6 port 53 { :: 1 ; }; #Service listening port is 53 (ipv6)
directory "/var/named" ; #Directory where configuration files are stored
dump- file "/var/named/data/cache_dump.db" ; #Cache of parsed content
statistics- file "/var/named/data/named_stats.txt" ; #Static cache (generally not used)
memstatistics- file "/var/named/data/named_mem_stats.txt" ; #Static cache (stored in memory, generally not used)
allow-query { localhost; }; #Allow connected clients
recursion yes; #Recursive search
dnssec-enable yes; #DNS encryption
dnssec-validation yes; #DNS encryption advanced algorithm
dnssec-lookaside auto; #DNS encryption related stuff
/* Path to ISC DLV key */
bindkeys- file "/etc/named.iscdlv.key" ; #Encryption key (private key and public key encryption, very strong)
};
logging { #Log
channel default_debug {
file "data/named.run" ; #Running status file
severity dynamic; #Static server address (root domain)
};
};
zone "." IN { #Root domain resolution
type hint; master slave
file "named.ca" ; #Root domain configuration file
};
include "/etc/named.rfc1912.zones" ; #Extended configuration file (new domain name)
/etc/named.rfc1912.zones
zone "localhost.localdomain" IN { #Local host full name resolution
type master; #Type is main domain
file "named.localhost" ; #Domain configuration file (files are stored in the /var/named directory)
allow-update { none; }; #Client updates are not allowed
};
zone "localhost" IN { #Local host name resolution
type master;
file "named.localhost" ;
allow-update { none; };
};
zone ".0.ip4.arpa" IN { #IPv6 local address reverse resolution
type master;
file "named.loopback" ;
allow-update { none; };
};
zone "1.0.0.127.in-addr.arpa" IN { #Local address reverse resolution
type master;
file "named.loopback" ;
allow-update { none; };
};
zone "0.in-addr.arpa" IN { #Local full network address reverse resolution (and/domain update)
type master;
file "named.empty" ;
allow-update { none; };
};
/var/named/named.localhost
$TTL 1D #Update to a maximum of 1 day
@(domain name of the domain being used) IN SOA (authoritative DNS server) @(name of the authoritative DNS server) rname.invalid.(rname @invalid email) (
0 ; serial #(change number) 10-digit serial number
1D ; update frequency
1H ; failed retry time
1W ; expiration time
3H ) ; cache time
NS (domain name server) @(domain name server name)
A (forward resolution record) 127.0 . 0.1 (forward resolution IP)
AAAA (ipv6 forward resolution) :: 1 (ipv6 forward resolution IP)
Setting up DNS server
Install DNS Server
Install the bind package
yum install bind
Start the service
systemctl start named.service
Set the auto-start status
systemctl enable named.service
Configuration Files
Configure the main configuration file
vim /etc/named.conf
changed to
listen-on-v6 port 53 { any; };
allow-query { any; };
Configuring the zones file
Forward parsing configuration
Add forward resolution
zone "lzy.com." IN {
type master ;
file "lzy.com.zone" ;
allow - update { none; };
};
Reverse analysis configuration
添加反向解析
zone "134.168.192.in-addr.arpa" IN {
tpye master;
file "134.168.192.zone";
allow-update { none; };
};
Configuring the Zone Profile
Copying Files
cp /var/named/named.empty /var/named/lzy.com.zone
cp /var/named/named.empty /var/named/134.192.168.zone
Modify permissions
chown :named zlt.com.zone
Forward parsing configuration
Design a forward resolution for the excesoft . com domain name, copy and rename /var/named/named . empty to excesoft . com . zone,
change the file group to named, and modify its content
$TTL 3H
@ IN SOA lzy . com. root . lzy . com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns . lzy . com.
dns A 192.168.134.139
www A 192.168.134.139
Reverse analysis configuration
Design reverse resolution for the excesoft.com domain name, copy and rename / var/named/named. empty to 137.168.192.zone , change the file group to named , and modify its content.
Configuring the Network Card
vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR1=192.168.134.139
NETMASK=255.255.255.0
GATEWAY=192.168.134.2
DNS1=192.168.134.139
Start DNS Server
systemctl start named.service
Check the configuration file
named-checkconf
Configuring the Client
Modify the configuration file
Modify the configuration file: #vim /etc/resolv.conf.
Write the following content:
excesoft.
nameserver 192.168.137.22
Testing DNS Servers
Test the DNS server
using the nslookup command on the client computer.
The spring recruitment has begun. If you are not adequately prepared, it will be difficult to find a good job during the spring recruitment.
Here is a big employment gift package for everyone. You can prepare for the spring recruitment and find a good job!