时间:2023-05-29 19:06:01 | 来源:网站运营
时间:2023-05-29 19:06:01 来源:网站运营
内网搭建DNS服务器:DNS:Domain Name Service,域名解析服务[root@jhr-hub ~]# yum -y install bind-utils bind bind-devel bind-libs[root@jhr-hub ~]# vim /etc/named.rfc1912.zones[root@jhr-hub ~]# [root@jhr-hub ~]# [root@jhr-hub ~]# [root@jhr-hub ~]# tail -n 10 /etc/named.rfc1912.zoneszone "chenby.cn" IN { type master; file "chenby.cn.zone"; };[root@jhr-hub ~]# [root@jhr-hub ~]# cd /var/named/[root@jhr-hub named]# lsdata dynamic named.ca named.empty named.localhost named.loopback pakho.zone slaves[root@jhr-hub named]# [root@jhr-hub named]# cp named.localhost chenby.cn.zone[root@jhr-hub named]# [root@jhr-hub named]# chown named.named chenby.cn.zone[root@jhr-hub named]# [root@jhr-hub named]# vim chenby.cn.zone[root@jhr-hub named]#
检查配置文件[root@jhr-hub named]# named-checkconf /etc/named.conf[root@jhr-hub named]# [root@jhr-hub named]# [root@jhr-hub named]# named-checkzone chenby.cn /var/named/chenby.cn.zone zone chenby.cn/IN: loaded serial 0OK[root@jhr-hub named]#
启动服务,并设置开机自启[root@jhr-hub named]# systemctl restart named[root@jhr-hub named]# [root@jhr-hub named]# systemctl enable namedCreated symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.[root@jhr-hub named]# 测试是否可行[root@jhr-hub named]# dig @3.7.191.1 www.chenby.cn; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.7 <<>> @3.7.191.1 www.chenby.cn; (1 server found);; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5275;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096;; QUESTION SECTION:;www.chenby.cn. IN A;; ANSWER SECTION:www.chenby.cn. 86400 IN A 3.7.191.1;; AUTHORITY SECTION:chenby.cn. 86400 IN NS chenby.cn.;; ADDITIONAL SECTION:chenby.cn. 86400 IN A 127.0.0.1chenby.cn. 86400 IN AAAA ::1;; Query time: 0 msec;; SERVER: 3.7.191.1#53(3.7.191.1);; WHEN: Thu Dec 09 14:44:51 CST 2021;; MSG SIZE rcvd: 116[root@jhr-hub named]#
附录:options {listen-on port 53 { 127.0.0.1; }; //设置named服务器监听端口及IP地址listen-on-v6 port 53 { ::1; };directory "/var/named"; //设置区域数据库文件的默认存放地址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";allow-query { any; }; //允许DNS查询客户端allow-query-cache { any; };};logging {channel default_debug {file "data/named.run";severity dynamic;};};view localhost_resolver {match-clients { any; };match-destinations { any; };recursion yes; //设置允许递归查询include "/etc/named.rfc1912.zones";};
2.区域配置文件/etc/named.rfc1912.zoneszone "." IN { //定义了根域type hint; //定义服务器类型为hintfile "named.ca"; //定义根域的配置文件名};zone "localdomain" IN { //定义正向DNS区域type master; //定义区域类型file "localdomain.zone"; //设置对应的正向区域地址数据库文件allow-update { none; }; //设置允许动态更新的客户端地址(none为禁止)};zone "localhost" IN {type master;file "localhost.zone";allow-update { none; };};zone "0.0.127.in-addr.arpa" IN { //设置反向DNS区域type master;file "named.local";allow-update { none; };};
3.根域配置文件http://named.ca$TTL 600@ IN SOA dns.cwlinux.com dnsadmin.cwlinux.com. (//SOA字段 2015031288 //版本号 同步一次 +1 1H //更新时间 2M // 更新失败,重试更新时间 2D // 更新失败多长时间后此DNS失效时间 1D //解析不到请求不予回复时间) IN NS dns //有两域名服务器 IN NS ns2 IN MX 10 mial // 定义邮件服务器,10指优先级 0-99 数字越小优先级越高ns2 IN A 192.168.1.113 //ns2域名服务器的ip地址dns IN A 192.168.1.10 //dns域名服务器的ip地址mail IN A 192.168.1.111 //邮件服务器的ip地址www IN A 192.168.1.112 //www.cwlinux.com的ip地址pop IN CNAME mail //pop的正式名字是mailftp IN CNAME www //ftp的正式名字是www
5.反向域名解析数据库文件$TTL 600@ IN SOA dns.cwlinux.com. dnsadmin.cwlinux.com. ( 2014031224 1H 2M 2D 1D) IN NS dns.cwlinux.com.10 IN PTR dns.cwlinux.com. //反向解析PTR格式111 IN PTR mail.cwlinux.com.112 IN PTR www.cwlinux.com.// 声明域的时候已经有了,192.168.1 所以我们只需要输入10即代表192.168.1.10jc
本文使用 文章同步助手 同步
关键词:服务