好物优选点击查看详情 京东购买

暂无内容

linux debian配置DNS域名解析服务器

master pc2 10.7.70.152 client pc1 10.7.70.151 pc3 10.7.70.153

一.安装

master安装bind9、resolvconf、dnsutils
client安装resolvconf

pc2:~ Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==============-===================-============-================================= ii bind9 1:9.16.22-1~deb11u1 amd64 Internet Domain Name Server 

启动服务

systemctl start named 

开机自启

systemctl enable named 

修改地址 并把dns改为服务机的ip地址

vim /etc/network/interfaces.d/50-cloud-init

     auto lo iface lo inet loopback auto ens3 iface ens3 inet static address 10.7.70.152 netmask 255.255.255.0 gateway 10.7.70.254 dns-nameserver 10.7.70.152 

重启网卡

pc2:~ 

查看dns地址

pc2:~     nameserver 10.7.70.152 

修改主配置文件

pc2:~ // prime the server with knowledge of the root servers zone "." { type hint; file "/usr/share/dns/root.hints"; }; // be authoritative for the localhost forward and reverse zones, and for // broadcast zones as per RFC 1912 zone "localhost" { type master; file "/etc/bind/db.local"; }; zone "127.in-addr.arpa" { type master; file "/etc/bind/db.127"; }; zone "0.in-addr.arpa" { type master; file "/etc/bind/db.0"; }; zone "255.in-addr.arpa" { type master; file "/etc/bind/db.255"; }; zone "70.7.10.in-addr.arpa" { type master; file "/etc/bind/db.70.7.10"; }; zone "example.com" { type master; file "/etc/bind/db.example.com"; } 

添加两条记录,一个是正向解析文件·,一个反向解析文件 域名为正向解析,地址为反向解析

type项的值:

master:表示定义的是主域名服务器

slave :表示定义的是辅助域名服务器

hint:表示是互联网中根域名服务器

file:表示指定区资源文件的位置

创建区资源文件

复制db.empty 到db.example.com db.70.7.10

pc2:~ bind.keys db.127 db.70.7.10 db.example.com named.conf named.conf.local rndc.key db.0 db.255 db.empty db.local named.conf.default-zones named.conf.options zones.rfc1918 

编辑正向解析文件 vim /etc/bind/db.exampty

; BIND reverse data file for empty rfc1918 zone ; ; DO NOT EDIT THIS FILE - it is used for multiple zones. ; Instead, copy it, edit named.conf, and use that copy. ; $TTL 86400 @ IN SOA localhost. root.localhost. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 86400 ) ; Negative Cache TTL ; @ IN NS localhost. pc1 IN A 10.7.70.151 pc2 IN A 10.7.70.152 pc3 In A 10.7.70.153            

编辑反向解析文件 vim /etc/bind/db.70.7.10

; BIND reverse data file for empty rfc1918 zone ; ; DO NOT EDIT THIS FILE - it is used for multiple zones. ; Instead, copy it, edit named.conf, and use that copy. ; $TTL 86400 @ IN SOA localhost. root.localhost. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 86400 ) ; Negative Cache TTL ; @ IN NS localhost. 151 IN PTR pc1.example.com 152 IN PTR pc2.example.com 153 IN PTR pc3.example.com ~            

nslookup ip地址/域名

pc2:/etc/bind > 10.7.70.151 151.70.7.10.in-addr.arpa name = pc1.example.com. > 10.7.70.152 152.70.7.10.in-addr.arpa name = pc2.example.com. > 10.7.70.153 153.70.7.10.in-addr.arpa name = pc3.exmaple.com. > pc1.example.com Server: 10.7.70.152 Address: 10.7.70.152 Name: pc1.example.com Address: 10.7.70.151 > pc2.example.com Server: 10.7.70.152 Address: 10.7.70.152 Name: pc2.example.com Address: 10.7.70.152 > pc3.example.com Server: 10.7.70.152 Address: 10.7.70.152 Name: pc3.example.com Address: 10.7.70.153 

原文链接:https://blog.csdn.net/qq_59360895/article/details/123385304

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享