ubuntu搭建dns服务器
来源:互联网 发布:javascript split 编辑:程序博客网 时间:2024/05/16 15:10
因为工作需要,需在局域网内搭建一台dns服务器。确实遇到一些问题,也有一些好的文章,作为记录。
1.安装:
sudo apt-get updatesudo 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 -> ipzone "test.com" in { type master; file "/var/cache/bind/db.test.com";};//ip -> domainzone "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.191ns IN A 192.168.0.191test01 IN A 192.168.0.191test02 IN A 192.168.0.192test10 IN A 192.168.1.100test10 IN A 192.168.1.101test10 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.comServer: 192.168.0.191Address: 192.168.0.191#53Name: test01.test.comAddress: 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搭建DNS服务器
- ubuntu搭建dns服务器
- ubuntu 搭建局域网内DNS服务器
- ubuntu搭建内网dns服务器
- Ubuntu系统搭建bind DNS服务器
- 在ubuntu 12.04上搭建简单的DNS服务器
- 搭建DNS服务器
- DNS服务器搭建
- CentOS DNS服务器搭建
- redhat dns服务器搭建
- 搭建DNS服务器
- DNS服务器搭建
- DNS服务器搭建笔记
- Linux 搭建DNS服务器
- Linux DNS服务器搭建
- 10.DNS服务器搭建
- DNS服务器搭建
- 搭建DNS服务器
- Cocos2d-x 屏幕适配新解
- AIDL遇到的问题
- 测试人员那点事
- 拓展log4j——在写日志时加入自己的逻辑.md
- Codeforces Round #419 (Div. 2)-贪心&思维-C. Karen and Game
- ubuntu搭建dns服务器
- R语言统计分析篇
- laya之坑--加密解密算法
- codeforces 846A Curriculum Vitae
- 04. Yii 2.0 的MVC模式
- Oracle获取所有的上级和下级 connect by
- My eclipse设置tab为4个空格
- 拓扑排序问题
- mysql集群——(二)环境搭建