Linux_DNS服务器

云物互联 发表于 2021/08/06 01:31:59 2021/08/06
【摘要】 目录 目录DNSDNS Server ServerSiteMaster DNS Server Forward DomainReverse Resolution Slave DNS Server Forward lookupReverse lookup Split DNS Server DNS DNS(Domain Name System,域...

目录

DNS

DNS(Domain Name System,域名系统),在Internet上作为域名和IP地址映射的一个分布式数据库,能够使用户更直观、更方便的访问互联网(域名更便于记忆),而不用去记住能够被机器直接读取的IP地址。通过主机名,最终得到该主机名对应的IP地址的过程叫做域名解析(或主机名解析)。所以DNS服务器的功能既是:域名、IP映射,DNS协议运行在UDP协议之上,使用端口号53。
hostname到IPaddress映射有两种方式
1) 静态映射,每台设备上都配置主机到IP地址的映射(hosts),各设备独立维护自己的映射表,而且只供本设备使用;
2) 动态映射,建立一套域名解析系统(DNS),只在专门的DNS服务器上配置主机到IP地址的映射,网络上需要使用主机名通信的设备,首先需要到DNS服务器查询主机所对应的IP地址。
注意:在解析域名时,可以首先采用静态域名解析的方法,如果静态域名解析不成功,再采用动态域名解析的方法。可以将一些常用的域名放入静态域名解析表中,这样可以大大提高域名解析效率。

DNS Server

ServerSite

vim named.conf

 opeions { # listen-on port 53 { 127.0.0.1; }; #Monitoring computer IP. General Comment. # listen-on-v6 post 53 { ::1; };  #As above directory "/etc/named";  #specify directory of store domain data coinfig file allow-query { any; };  #specify DNSServer response network segment, 'any' mean that all network segment. }; zone "." IN { type hint; file "name.ca"; #record 13 root DNSServerIP }
  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

Master DNS Server

step1.

yum install -y bind bind-chroot
  
 
  • 1

step2. Edit the config file.
vim /etc/named.conf

 opeions { # listen-on port 53 { 127.0.0.1; }; #monitoring computer IP, General comments. # listen-on-v6 post 53 { ::1; }; #Idem directory "/etc/named";  #specify directory of store domain data coinfig file allow-query { any; };   #specify DNSServer response network segment, any mean that all network segment. };
  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Forward Domain

vim /etc/name.rf1912.zone

 zone "fan.com" IN { type master; file "fan.com.zone";  #need create in the /var/named/fan.com.zone by manual allow-update { none; }; };
  
 
  • 1
  • 2
  • 3
  • 4
  • 5

Create zone config file:

cp -p /var/named/named.localhost /var/named/fan.com.zone
  
 
  • 1

vim fan.com.zone

 @ NS hostname.domain.   #one NS flag have to mapping one A flay hostname A 192.168.1.144 www A 192.168.1.145 ftp A 192.168.1.146 @ MX 10 mail.fan.com.
  
 
  • 1
  • 2
  • 3
  • 4
  • 5

Reverse Resolution

vim /etc/name.rf1912.zone

 zone "1.168.192.in-addr.arpa" IN { type master; file "192.168.1.zone"; allow-update { none; }; };
  
 
  • 1
  • 2
  • 3
  • 4
  • 5

Create zone config file:

cp -p /var/named/named.localhost /var/named/192.168.1.zone
  
 
  • 1

vim 192.168.1.zone

 @ NS hostname.domain. 145 PTR  www.fan.com. 146 PTR ftp.fan.com.
  
 
  • 1
  • 2
  • 3

step3. Start named service

service named restart
  
 
  • 1

Slave DNS Server

step1. Edit Slave dns server’s named.conf file same as master server
step2. Edit the named.rf1912.zones

Forward lookup:

vim /etc/named.rf1912.zones

 zone "fan.com" IN { type slave; masters { MasterServerIP; }; file "slaves/fan.com.zone.slave";  #in the /var/names/slaves/ directory };
  
 
  • 1
  • 2
  • 3
  • 4
  • 5

Reverse lookup:

vim /etc/named.rf1912.zones

 zone "1.168.192.in-addr.arpa" IN { type slave; masters { MasterServerIP; }; file "slaves/192.168.1.zone.slave"; };
  
 
  • 1
  • 2
  • 3
  • 4
  • 5

step3.

service named restart
  
 
  • 1

Split DNS Server

step1. Edit the DNSServer main config file
vim /etc/named.conf

#Comment the root node and line of 'include "/etc/named.rf1912.zone"' #zone "." IN { # type hint; # file "named.ca"; #}; #include "/etc/named.rf1912.zone"
  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

step2. Add view for public network and private network
Attention:First setting LAN then setting WAN .
vim /etc/named.conf
privateNetwork

 view "lan(viewName)" { match-clients { 1992.168.1.0/24; };   #specify split uplook domain networkSepment. zone "fan.com" IN { #define the uplook domain type master; file "fan.com.zone" notify yes; #allow tthe DNSServer update also-notify { 192.168.1.2; }; #assign to the dns slave server }; };
  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

publicNetwork

 view "wan" { match-clients { any; }; zone "fan.com" IN { type master; file "fan.com.zone" }; };
  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

step3. Create the domain date file in directory with “/var/named” and restart named service.

文章来源: is-cloud.blog.csdn.net,作者:范桂飓,版权归原作者所有,如需转载,请联系作者。

原文链接:is-cloud.blog.csdn.net/article/details/50196293

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:cloudbbs@huaweicloud.com进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。