標籤:配置dns伺服器 linux dns
一、安裝
yum install bind-utils.x86_64
yum install bind
二、配置
vim /etc/named.conf
編輯檔案內容為:
############################################################
options {
listen-on port 53 { 127.0.0.1;192.168.4.103; };
directory "/var/named";
allow-query { any; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "example.com" IN {
type master;
file "example.com.zone";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
###########################################################
[[email protected] Desktop]# cd /var/named/
[[email protected] named]# cp named.localhost example.com.zone -p
[[email protected] named]# vim example.com.zone
修改為:
###############################################################
$TTL 1D
@ IN SOA @ root.server03.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
server03 IN A 192.168.4.103
###################################################################
[[email protected] named]# /etc/init.d/named restart
指定DNS伺服器:
[[email protected] named]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
添加:
DNS1=192.168.4.254
重啟網卡:
[[email protected] named]# /etc/init.d/network restart
測試:
[[email protected] named]# nslookup server03
Server: 192.168.4.103
Address: 192.168.4.103#53
Name: server03.example.com
Address: 192.168.4.103
[[email protected] named]# nslookup server03.example.com
Server: 192.168.4.103
Address: 192.168.4.103#53
Name: server03.example.com
Address: 192.168.4.103
三、將ip位址解析成網域名稱
編輯name.conf檔案:
新增內容:
zone "4.168.192.in-addr.arpa" IN {
type master;
file "192.168.4.zone";
};
[[email protected] named]# pwd
/var/named
[[email protected] named]# cp example.com.zone 192.168.4.zone -p
編輯192.168.4.zone 檔案:
修改為:
$TTL 1D
@ IN SOA @ root.server03.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
103 IN PTR server03.example.com.
重啟named
[[email protected] named]# /etc/init.d/named restart
測試:
[[email protected] named]# nslookup 192.168.4.103
Server: 192.168.4.103
Address: 192.168.4.103#53
103.4.168.192.in-addr.arpa name = server03.example.com.
四、讓DNS伺服器變得安全
安裝bind-chroot
!!!停止named服務
[[email protected] named]# service named stop
安裝:
[[email protected] named]# yum install bind-chroot
[[email protected] named]# cd /var/named/chroot/etc/
[[email protected] etc]# cp /etc/named* ./ -p
[[email protected] etc]# cd ../var/named/
[[email protected] named]# ls 為空白為正常
[[email protected] named]# cp -rp /var/named/* ./
[[email protected] named]# rm -rf chroot/
[[email protected] named]# ls
192.168.4.zone dynamic named.ca named.localhost slaves
data example.com.zone named.empty named.loopback
不能有chroot
[[email protected] named]# cd /var/named
[[email protected] named]# pwd
/var/named
[[email protected] named]# rm -rf example.com.zone
[[email protected] named]# rm -rf 192.168.4.zone
重啟服務:
[[email protected] etc]# /etc/init.d/named restart
Stopping named: [ OK ]
Starting named: [ OK ]
驗證:
[[email protected] etc]# nslookup server03.example.com
Server: 192.168.4.103
Address: 192.168.4.103#53
Name: server03.example.com
Address: 192.168.4.103
[[email protected] etc]# nslookup 192.168.4.103
Server: 192.168.4.103
Address: 192.168.4.103#53
103.4.168.192.in-addr.arpa name = server03.example.com.
現在named.comf 使用的是/var/named/chroot/etc/named.conf
Ok!
配置DNS伺服器