DNS

ubuntu |DNS 服务器搭建

Posted by Elli0t on 2020-06-14

bind9

安装apt-get install bind9

配置/etc/bind/named.conf.local 文件(服务器域解析文件)

这个是:让域名到 ip

image-20200614155410122

1
2
3
4
zone "baidu.com" IN {                                                                                         
type master;
file "/etc/bind/db.baidu.com";
};

编辑域解析文件

将模版复制一下cp /etc/bind/db.local /etc/bind/db.baidu.com

image-20200614155543132

这里的 localhost 是主机名,182.261.204.208 是域名对应服务器 IP

修改 /etc/bind/named.conf.options 文件为如下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
options {
directory "/var/cache/bind";

// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.

forwarders {
8.8.8.8;
};

//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;

auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};

其实只需要修改

forwarders {
   8.8.8.8;
};

nslookup www.baidu.com 查看是否成功,如果没有可以试着修改 ubuntu 的 DNS 来源,修改为本机。

查看端口情况netstat -antp

最后在安全组策略中开一下 53 端口

image-20200614111025957

image-20200614111005134

参考链接

centos: https://www.jianshu.com/p/3d9d41521f82

ubuntu: https://www.jianshu.com/p/d1aa723e066c

https://blog.51cto.com/14284354/2383573

https://blog.csdn.net/change_on/article/details/78376830