某校园网要架设一台主DNS服务器负责linux-xxx域(xxx为姓名拼音或首字母)的域名解析工作,服务器IP地址为192.168.1.学号。 要求:1、为以下域名实现正向和反向域名解析服务。 dns.linux-xxx.com 192.168.1.学号 mail.linux-xxx.com MX记录 192.168.1.180 study.linux-xxx.com 192.168.1.181 teach.linux-xxx.com 192.168.1.182 www.linux-xxx.com 192.168.1.183 2、配置从DNS服务器,IP地址为192.168.1.199 3、其它虚拟机设置以上主从DNS服务器测试正常。 4、windows主机设置以上主从DNS服务器测试正常。在Centos7完成这些要求,并给出具体步骤。
时间: 2023-12-06 21:41:58 浏览: 171
以下是在CentOS 7上完成这些要求的具体步骤:
1. 安装BIND软件包:
```
yum install bind bind-utils -y
```
2. 编辑主DNS服务器的配置文件`/etc/named.conf`,添加以下内容:
```
acl "trusted" {
192.168.1.0/24;
localhost;
};
options {
directory "/var/named";
recursion yes;
allow-query { trusted; };
forwarders { 8.8.8.8; };
};
zone "linux-xxx.com" IN {
type master;
file "linux-xxx.com.zone";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "1.168.192.in-addr.arpa.zone";
allow-update { none; };
};
```
3. 创建正向解析区域文件`/var/named/linux-xxx.com.zone`,添加以下内容:
```
$TTL 86400
@ IN SOA dns.linux-xxx.com. root.linux-xxx.com. (
2021100101; Serial
3600; Refresh after 3 hours
900; Retry after 15 minutes
604800; Expire after 1 week
86400); Minimum TTL of 1 day
@ IN NS dns.linux-xxx.com.
dns.linux-xxx.com. IN A 192.168.1.学号
mail.linux-xxx.com. IN MX 10 192.168.1.180
study.linux-xxx.com. IN A 192.168.1.181
teach.linux-xxx.com. IN A 192.168.1.182
www.linux-xxx.com. IN A 192.168.1.183
```
4. 创建反向解析区域文件`/var/named/1.168.192.in-addr.arpa.zone`,添加以下内容:
```
$TTL 86400
@ IN SOA dns.linux-xxx.com. root.linux-xxx.com. (
2021100101; Serial
3600; Refresh after 3 hours
900; Retry after 15 minutes
604800; Expire after 1 week
86400); Minimum TTL of 1 day
@ IN NS dns.linux-xxx.com.
学号 IN PTR dns.linux-xxx.com.
180 IN PTR mail.linux-xxx.com.
181 IN PTR study.linux-xxx.com.
182 IN PTR teach.linux-xxx.com.
183 IN PTR www.linux-xxx.com.
```
5. 启动并开机自启BIND服务:
```
systemctl start named
systemctl enable named
```
6. 编辑从DNS服务器的配置文件`/etc/named.conf`,添加以下内容:
```
options {
directory "/var/named";
recursion yes;
allow-query { any; };
};
zone "linux-xxx.com" IN {
type slave;
masters { 192.168.1.学号; };
file "slaves/linux-xxx.com.zone";
};
zone "1.168.192.in-addr.arpa" IN {
type slave;
masters { 192.168.1.学号; };
file "slaves/1.168.192.in-addr.arpa.zone";
};
```
7. 启动并开机自启BIND服务:
```
systemctl start named
systemctl enable named
```
8. 在其它虚拟机和Windows主机上配置主从DNS服务器的IP地址,测试解析是否正常。
注意:在上述步骤中,需要将其中的`linux-xxx.com`和`学号`替换为具体的域名和IP地址。在创建区域文件时,需要注意修改文件名和目录路径,以避免与已有文件重名。
阅读全文