What is DNS
The information transmission of computers in local area network is based on IP address to identify identity, and it is also completed through IP address in the Internet. DNS just came into being. In order to reduce the threshold for users to access the network. This is a technology used to manage and resolve the correspondence between domain name and IP address. In short, it can accept the domain name or IP address entered by the user, and then automatically find the matching (or mapping) IP address or domain name, that is, the domain name is resolved to IP address (forward resolution), or the IP address is resolved to domain name (reverse resolution). In this way, we only need to enter the domain name in the browser to open the website we want to visit. The forward resolution of DNS domain name resolution technology is also one of the most commonly used working modes.
DNS three profile lists
The main configuration file (/ etc/named.conf): there are only 58 lines, and after removing the comment information and empty lines, the actual valid parameters are only about 30 lines. These parameters are used to define the operation of the bind service program.
Zone configuration file (/ etc/named.rfc1912.zones): used to save the location of the corresponding relationship between domain name and IP address. Similar to the directory of books, it corresponds to the specific location of each domain and corresponding IP address. When you need to view or modify, you can find relevant files according to this location.
Data configuration file directory (/ var/named): this directory is used to save the data configuration file of the real correspondence between domain name and IP address.
Install DNS server
!!! Note that the comments in the article should not appear in the configuration file to prevent errors
yum install bind //Install DNS service; yum install bind / / install DNS service; yum install bind-utils //Install nslookup tool
Edit named Conf configuration file
vim /etc/named.conf
listen-on port 53 { 192.168.135.157; }; //newly added listen-on port 53 { any; }; //newly added //listen-on-v6 port 53 { ::1; }; // Comment out the original directory "/var/named"; //Defines the directory location of the forward and reverse configuration files dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; secroots-file "/var/named/data/named.secroots"; recursing-file "/var/named/data/named.recursing"; //allow-query { localhost; }; // Comment out the original allow-query { any;}; //newly added
Check for syntax errors
named-checkconf #If an error is reported, modify the error according to the specific number of error lines
Writing a forward resolution profile cd /var/named/ vim zut.com.zone
$TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 192.168.135.157 //Add A record for native IP www A 192.168.135.157 //Add A record of WWW, i.e. www.zut com AAAA ::1
Writing a reverse resolution configuration file cd /var/named/ vim zut.com.local
$TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ AAAA ::1 157 PTR www.zut.com
Edit server profile
vim /etc/named.rfc1912.zones
Add "forward" and "reverse" configurations at the end of the file,
//Forward zone configuration zone "zut.com"IN { type master; file "zut.com.zone"; allow-update{none;}; }; //Reverse zone configuration zone "135.168.192.in-addr.arpa"IN{ type master; file "zut.com.local"; allow-update{none;}; };
Restart DNS server
systemctl restart named
test
We use another linux as the client and the configured DNS server as its DNS server (note that the two hosts should be on the same virtual network card)
vim /etc/resolv.conf
nslookup www.zut.com Forward test successful
Reverse test
nslookup www.zut.com forward test succeeded
Reverse test
Reference article: https://blog.csdn.net/litiammmm/article/details/111685169