ubuntu下配置bind9为局域网的DNS服务器
一、配置bind9服務器之前,先了解這些知識點:
1、DNS解析過程詳解:http://www.cnblogs.com/liyuanhong/articles/7353974.html
2、常用域名記錄解釋(A記錄,CNAME,NS記錄,MX記錄):http://www.cnblogs.com/liyuanhong/articles/7355153.html
3、bind9簡介:http://www.cnblogs.com/liyuanhong/articles/7400651.html
4、bind9基本配置講解:http://www.cnblogs.com/liyuanhong/articles/7400854.html
二、開始在ubuntu上配置bind9作為局域網的域名服務器
1、bind9的安裝,這里假設bind9通過apt-get已經裝上
2、進入/etc/bind目錄下面
3、創建一個區域記錄文件(類似這樣db.xxx的文件):這里我創建了db.testlyhh.com
4、編輯named.conf.default-zones文件,添加如下:
zone "testlyhh.com" {type master;file "/etc/bind/db.testlyhh.com"; #指明區域記錄文件的位置 }; 5、編輯我們的區域記錄文件db.testlyhh.com,如下:【在此之前,先普及一個小知識: 域名www.baidu.com完整的域名應該是這樣的,www.baidu.com. 最后又一個小點,代表根域名:
? ? baidu.com.代表的是域
? ? www其實是baidu.com.域內的一臺主機,名字叫www
? ? 所以一下的配置aaa、bbb、ccc其實都是一臺主機;我們指定了ccc主機的別名又叫bbb
? ? 具體參見上面的:DNS解析過程詳解
】
$TTL 604800 @ IN SOA testlyhh.com. root.localhost. (1 ; Serial604800 ; Refresh86400 ; Retry2419200 ; Expire604800 ) ; Negative Cache TTL ; @ IN NS localhost. testlyhh.com IN NS 192.168.1.108aaa IN A 192.168.1.108 bbb IN A 192.168.1.108 ccc IN CNAME bbb 6.編輯named.conf.options文件,為局域網其他機器提供dns服務(修改option的listen-on語句): //acl "trusted" { // 127.0.0.1; # ns1 - can be set to localhost // 192.168.1.108; # ns2 //};options {directory "/var/cache/bind";//recursion yes; # 啟用遞歸尋址//allow-recursion { trusted; }; # 允許“trusted”列表前來遞歸尋址listen-on port 53 {127.0.0.1;192.168.1.108; }; # 此處填寫ns1的內網IP地址。僅在內網監聽allow-transfer { none; }; # 默認禁用zone transfer// 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 {// 0.0.0.0;// };//========================================================================// 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 RFC1035listen-on-v6 { any; }; };配置完成,重啟服務: service bind9 restart展示一下我的/etc/bind目錄內容:
7、接下來看看DNS配置是否生效,首先在ubuntu本機上指明我們的bind9服務器地址:
需要編輯:?/etc/resolv.conf文件,在nameserver的開頭之前加入一行,指明域名:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 192.168.1.108 #nameserver 127.0.1.1 search DHCP HOST接下來ping ?aaa.testlyhh.com:
到此域名配置成功。
三、配置局域網自動獲取配置好的DNS服務器地址:
如果現在局域網內自動給電腦分配我們配置的DNS服務器,則只需在搭建DHCP分配IP時把DNS自動指定成配好的DNS即可
總結
以上是生活随笔為你收集整理的ubuntu下配置bind9为局域网的DNS服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解决windows10 wireshar
- 下一篇: excel常用公式整理