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?ops_request_misc=&request_id=&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-20-123385304-null-null.268%5Ev1%5Ekoosearch&utm_term=%E9%BB%91%E7%BE%A4%E6%99%96%E3%80%81docker%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81%E5%9F%9F%E5%90%8D%E6%B3%A8%E5%86%8C%E3%80%81%E5%AE%9D%E5%A1%94%E3%80%81%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E3%80%81nginx%E3%80%81frp%E3%80%81%E5%8A%A8%E6%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E3%80%81NAS%E3%80%81%E7%BE%A4%E6%99%96%E3%80%81%E9%98%BF%E9%87%8C%E4%BA%91%E3%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E3%80%81%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E3%80%81ipv6%E3%80%81ddns%E3%80%81%E8%BD%BB%E9%87%8F%E7%BA%A7%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E9%93%81%E5%A8%81%E9%A9%AC%E3%80%81%E5%A8%81%E8%81%94%E9%80%9A%E3%80%81DSM%E3%80%81DSM6.0%E3%80%81%E7%BE%A4%E6%99%96nas%E3%80%81%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E8%9C%97%E7%89%9B%E6%98%9F%E9%99%85%E3%80%81

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