1.安装bind9
sudo apt-get install bind9
2.编辑文件
sudo vi /etc/bind/named.conf.local
加入字段:
其中example是要配置的域名,第二个节为反响映射
zone "example.com" {
type master;
file "/etc/bind/zones/example.com.db";
};
# This is the zone definition for reverse DNS. replace 0.168.192 with your network address in reverse notation - e.g my network address is 192.168.0
zone "0.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.0.168.192.in-addr.arpa";
};
3.编辑文件
配置网络提供商的dns服务器
sudo vi /etc/bind/named.conf.options
forwarders {
# Replace the address below with the address of your provider's DNS server
123.123.123.123;
};
4.编辑example域名配置的文件
sudo vi /etc/bind/zones/example.com.db
内容:
example.com. IN SOA ns1.example.com. admin.example.com. (
2006081401
28800
3600
604800
38400
)
example.com. IN NS ns1.example.com.
example.com. IN MX 10 mta.example.com.
IN A 192.168.37.160
www IN A 192.168.37.160
mta IN A 192.168.37.3
ns1 IN A 192.168.37.1
sudo vi /etc/bind/zones/rev.0.168.192.in-addr.arpa
@ IN SOA ns1.example.com. admin.example.com. (
2006081401;
28800;
604800;
604800;
86400
)
IN NS ns1.example.com.
1 IN PTR example.com
5.编辑文件
sudo vi /etc/resolv.conf
search example.com
nameserver 192.168.0.1
6. 重启bind9服务
/etc/init.d/bind9 restart 生效
7.重启后可以查看系统日志/var/log/syslog 是否出错。