ubuntu搭建dns服务器
2017-09-07 20:45
162 查看
因为工作需要,需在局域网内搭建一台dns服务器。确实遇到一些问题,也有一些好的文章,作为记录。
1.安装:
2.修改/etc/bind/named.conf.local文件
这里是配置一个 主dns 服务器,所以配置为master,如果需要配置备份服务器,配置为slave。
⚠️配置文件中的两个文件,一个域名到ip的解析,一个是ip到域名的解析。
3.配置域名到IP解析文件:/var/cache/bind/db.test.com
⚠️ 除了“root.test.com.”前后是空格之外,其它均为tab⚠️
上图中配置了一个域名对应多个ip 的情况,cname的配置不详述
4.修改IP到域名解析的文件:/var/cache/bind/db.0.168.192
⚠️ 注意域名后面的”.”⚠️
5.在 /etc/bind/named.conf.option中做些文件日志位置指向
⚠️这一步是参考别的文档填写的,具体用处暂时说不上来,哈哈
6.确认本机dns nameserver 已经设置
文件路径:/etc/resolv.conf
我的机子好像默认有nameserver 127.0.0.1
如果没有配置的话,解析域名会失败,关注。
7.重启bind9服务
8.测试 使用host 或者nslookup
yeah!测试通过!
如果出现问题,建议多看日志,在搭建的时候第一次重启,服务没有启动,看日志解决的,后来又一次,修改了db.test.com,重启之后,发包使用wireshark 抓包,发现“server failure”再查看日志,发现原来IP 地址的格式有问题,超过了255汗。。。总之出现问题多看日志。
参考链接如下:
搭建过程:http://www.linuxidc.com/Linux/2015-04/116350.htm
配置文件中各字段:http://blog.csdn.net/aly1989/article/details/51096890
dns负载均衡说明:http://blog.csdn.net/cywosp/article/details/38017027
1.安装:
sudo apt-get update sudo apt-get install bind9 bind9utils bind9-doc
2.修改/etc/bind/named.conf.local文件
// // Do any local configuration here // // Consider adding the 1918 zones here, if they are not used in your // organization //include "/etc/bind/zones.rfc1918"; //domain -> ip zone "test.com" in { type master; file "/var/cache/bind/db.test.com"; }; //ip -> domain zone "0.168.192.in-addr.arpa" in { type master; file "/var/cache/bind/db.0.168.192"; };
这里是配置一个 主dns 服务器,所以配置为master,如果需要配置备份服务器,配置为slave。
⚠️配置文件中的两个文件,一个域名到ip的解析,一个是ip到域名的解析。
3.配置域名到IP解析文件:/var/cache/bind/db.test.com
; ;BIND data file for local loopback interface ; $TTL 604800 @ IN SOA test.com. root.test.com. ( 2 ;Serial 604800 ;Refresh 86400 ;Retry 2419200 ;Expire 604800 ) ;Negative Cache TTL ; @ IN NS ns.test.com. @ IN A 192.168.0.191 ns IN A 192.168.0.191 test01 IN A 192.168.0.191 test02 IN A 192.168.0.192 test10 IN A 192.168.1.100 test10 IN A 192.168.1.101 test10 IN A 192.168.1.102
⚠️ 除了“root.test.com.”前后是空格之外,其它均为tab⚠️
上图中配置了一个域名对应多个ip 的情况,cname的配置不详述
4.修改IP到域名解析的文件:/var/cache/bind/db.0.168.192
$TTL 604800 @ IN SOA test.com. root.test.com. ( 2 ;Serial Number 604800 ;Refresh 86400 ;Retry 2419200 ;Expire 86400 ); ;Minimum @ IN NS test.com. 191 IN PTR ns.test.com. 191 IN PTR test.test.com. 191 IN PTR test01.test.com. 192 IN PTR test02.test.com.
⚠️ 注意域名后面的”.”⚠️
5.在 /etc/bind/named.conf.option中做些文件日志位置指向
//dump-file "/var/cache/bind/cache_dump.db"; 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. dump-file "/var/cache/bind/cache_dump.db"; statistics-file "/var/cache/bind/named.stats"; managed-keys-directory "/etc/bind"; // forwarders { // 0.0.0.0; // }; allow-query { any; };
⚠️这一步是参考别的文档填写的,具体用处暂时说不上来,哈哈
6.确认本机dns nameserver 已经设置
文件路径:/etc/resolv.conf
我的机子好像默认有nameserver 127.0.0.1
如果没有配置的话,解析域名会失败,关注。
7.重启bind9服务
sudo service bind9 restart
8.测试 使用host 或者nslookup
$ host test01.test.com
$ nslookup >test01.test.com Server: 192.168.0.191 Address: 192.168.0.191#53 Name: test01.test.com Address: 192.168.0.191
yeah!测试通过!
如果出现问题,建议多看日志,在搭建的时候第一次重启,服务没有启动,看日志解决的,后来又一次,修改了db.test.com,重启之后,发包使用wireshark 抓包,发现“server failure”再查看日志,发现原来IP 地址的格式有问题,超过了255汗。。。总之出现问题多看日志。
tail -20 /var/log/syslog
参考链接如下:
搭建过程:http://www.linuxidc.com/Linux/2015-04/116350.htm
配置文件中各字段:http://blog.csdn.net/aly1989/article/details/51096890
dns负载均衡说明:http://blog.csdn.net/cywosp/article/details/38017027
相关文章推荐
- 在ubuntu 12.04上搭建简单的DNS服务器
- ubuntu_内网dns服务器搭建
- ubuntu搭建内网dns服务器
- ubuntu 搭建局域网内DNS服务器
- Ubuntu搭建DNS服务器
- Ubuntu 12.04 Server 搭建DNS服务器
- Ubuntu系统搭建bind DNS服务器
- ubuntu搭建dns服务器
- Ubuntu10.04 搭建DNS服务器
- Ubuntu Server搭建svn服务以及迁移方法【转】
- Ubuntu 12.04搭建Ruby on Rails开发环境
- Ubuntu16.04搭建HA集群hadoop-2.7.4
- ubuntu使用apache+php搭建博客学习笔记(复习笔记)(未完,持续更新中)
- Spark-1.6.1 Hadoop-2.6.4 VMware Ubuntu 分布式集群搭建 全过程
- Ubuntu下开发环境搭建 C|C++|GTK等
- ubuntu 13.10 下在eclipse下搭建python开发环境
- Ubuntu下Eclipse搭建Hadoop开发环境
- Openface在Ubuntu系统下的环境搭建(使用Anaconda管理,在Ubuntu14.04与16.04上都有效)
- Ubuntu-14.04.5搭建Hadoop-2.9.0分布式集群环境
- ubuntu 14.04-64x搭建android环境