centos7 安装dns
时间: 2023-11-22 15:06:15 浏览: 71
详解如何在 CentOS7.0 上搭建DNS 服务器
5星 · 资源好评率100%
以下是在CentOS 7上安装DNS的步骤:
1.使用yum安装bind和bind-utils软件包:
```shell
sudo yum install -y bind bind-utils
```
2.编辑主配置文件`/etc/named.conf`,添加区域配置文件:
```shell
sudo vi /etc/named.conf
```
在文件末尾添加以下内容:
```
zone "lml.com" IN {
type master;
file "/var/named/lml.com.zone";
allow-update { none; };
};
zone "168.192.in-addr.arpa" IN {
type master;
file "/var/named/159.168.192.zone";
allow-update { none; };
};
```
3.创建正向解析配置文件`/var/named/lml.com.zone`,并添加以下内容:
```shell
sudo vi /var/named/lml.com.zone
```
```
$TTL 86400
@ IN SOA ns1.lml.com. root.lml.com. (
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS ns1.lml.com.
ns1 IN A 192.168.159.130
www IN A 192.168.159.130
```
4.创建反向解析配置文件`/var/named/159.168.192.zone`,并添加以下内容:
```shell
sudo vi /var/named/159.168.192.zone
```
```
$TTL 86400
@ IN SOA ns1.lml.com. root.lml.com. (
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS ns1.lml.com.
130 IN PTR ns1.lml.com.
```
5.启动DNS服务并设置开机自启:
```shell
sudo systemctl start named
sudo systemctl enable named
```
6.修改网卡配置文件`/etc/sysconfig/network-scripts/ifcfg-eth0`,将DNS服务器地址设置为本机IP地址:
```shell
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
```
添加以下内容:
```
DNS1=192.168.159.130
```
7.重启网络服务:
```shell
sudo systemctl restart network
```
阅读全文