1.DNS反向解析(将IP地址解析为域名)
[root@dns ~]# vim /etc/named.rfc1912.zones
zone "1.168.192.in-addr.arpa" IN {
type master;
file "192.168.1.zone";
allow-update { none; };
};
[root@dns ~]# cd /var/named/
[root@dns named]# cp -p named.loopback 192.168.1.zone
[root@dns named]# vim 192.168.1.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
PTR localhost.
225 PTR www.tdr.tds
[root@dns named]# systemctl restart named
测试(client):
[root@client ~]# nslookup 192.168.1.225
225.1.168.192.in-addr.arpa name = www.tdr.tds.1.168.192.in-addr.arpa.
2.时间服务器
创建一台ntp服务器(192.168.1.250)
[root@ntp ~]# yum search ntpdate //查找ntpdate
[root@ntp ~]# yum -y install ntpdate.x86_64
[root@ntp ~]# systemctl restart network //重启网卡,必须能通外网才能同步时间
[root@ntp ~]# ntpdate cn.ntp.org.cn
[root@ntp ~]# date
2024年 07月 24日 星期三 14:30:31 CST
[root@ntp ~]# yum -y install ntp
[root@ntp ~]# vim /etc/ntp.conf
restrict 192.168.1.0 mask 255.255.255.0
[root@ntp ~]# ntpdate cn.ntp.org.cn //同步时间
24 Jul 15:26:10 ntpdate[1832]: step time server 192.168.1.250 offset 473395863.419243 sec
[root@ntp ~]# systemctl start ntpd //重启服务
[root@ntp ~]# crontab -e //设置计划任务,每天四点更新时间
* 4 * * * /usr/sbin/ntpdate cn.ntp.org.cn
测试:
[root@client ~]# ntpdate 192.168.1.250 //去客户机测试
[root@client ~]# date
2024年 07月 24日 星期三 15:14:39 CST //已经同步
三、主从DNS
创建一台从dns服务器(192.168.1.126)
在主dns服务器
[root@dns ~]# vim /etc/named.conf
options {
listen-on port 53 { 127.0.0.1;any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
allow-transfer {192.168.1.126; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { localhost;any; };
[root@dns ~]# systemctl restart named
去从dns服务器:
[root@cdns ~]# yum -y install bind
options {
listen-on port 53 { 127.0.0.1;any; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { localhost;any; };
[root@cdns ~]# vim /etc/named.rfc1912.zones
zone "tdr.tds" IN {
type slave;
file "slaves/tdr.tds.zone";
masters {192.168.1.125;};
};
[root@cdns ~]# systemctl restart named
去客户机测试:
[root@client ~]# echo "nameserver 192.168.1.125" > /etc/resolv.conf //指定DNS测试
[root@client ~]# nslookup www.tdr.tds
Server: 192.168.1.125
Address: 192.168.1.125#53
Name: www.tdr.tds
Address: 192.168.1.225
[root@client ~]# echo "nameserver 192.168.1.126" > /etc/resolv.conf
[root@client ~]# nslookup www.tdr.tds
Server: 192.168.1.126
Address: 192.168.1.126#53
Name: www.tdr.tds
Address: 192.168.1.225
四、多域名解析
1.在/etc/named.rfc1912.zones下
zone "xx.cc" IN {
type master;
file "xx.cc.zone";
allow-update { none; };
};
zone "yy.zz" IN {
type master;
file "yy.zz.zone";
allow-update { none; };
};
2.
[root@dns named]# cd /var/named/
[root@dns named]# cp -p named.localhost xx.cc.zone
[root@dns named]# cp -p named.localhost yy.zz.zone
[root@dns named]# vim xx.cc.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
www A 192.168.1.225
[root@dns named]# vim yy.zz.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
tt A 192.168.1.225
3.客户机测试:
nslookup www.xx.cc
nslookup tt.yy.zz