Ubuntu DNS bind9 配置

下面的配置就是实现解析test.zp.com到不同的IP地址

安装dns server软件包
$ apt-get install bind9

配置dns
配置文件的路径在/etc/bind路径下面
添加一个zone
$ /etc/bind# vim /etc/bind/named.conf.local
添加下面,语法可以参照/etc/bind/zones.rfc1918中的语法添加,如下:

zone "zp.com" { type master; file "/etc/bind/db.zp.com"; };

修改db的配置文件
$ /etc/bind# cp db.local db.zp.com
$ /etc/bind# vim db.zp.com
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA zp.com. root.localhost. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
@ IN A 127.0.0.1
@ IN AAAA ::1
test IN A 192.168.0.11
test IN A 192.168.0.12
test IN A 192.168.0.13
test IN A 192.168.0.14
test IN A 192.168.0.15
test IN A 192.168.0.16


修改/etc/bind/named.conf.option 配置文件,在 named.conf 中可以设置 bind 的 round-robin 的给出结果的顺序:

rrset-order { order cyclic; };

rrset-order 支持三个参数:fixed, random, cyclic 。
fixed 会将多个A记录按配置文件的顺序固定给出
random 会随机给出
cyclic 会循环给出
重启服务
$ /etc/bind# /etc/init.d/bind9 restart
检查配置效果
修改域名解析配置文件
$ /etc/bind# vim /etc/resolv.conf
nameserver 192.168.0.***
添加你的域名服务器的IP地址
$ dig test.zp.com

更加简单的选择  dnsmasq

原文地址:https://www.cnblogs.com/zhangeamon/p/5121663.html