Configure DNS view in Centos 7.1
Overview:
1. Prepare the environment
2. Configure the master configuration file
3. Configure the region File
4. Start the service and Test
------------------------------------
1. Environment preparation:
OS:
Software Installation
~]
#yuminstallbindbind-utils
[root@dns~]
#rpm-qa|grepbind
bind-license-9.9.4-18.el7_1.5.noarch
bind-utils-9.9.4-18.el7_1.5.x86_64
bind-libs-9.9.4-18.el7_1.5.x86_64
bind-libs-lite-9.9.4-18.el7_1.5.x86_64
bind-9.9.4-18.el7_1.5.x86_64
Disable firewall and selinux
~]
#systemctlstopfirewalld
~]
#setenforce0
Simulate two different network segments for host name resolution
Two Nic IP addresses:
[root@dns~]
#ipa
1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWN
link
/loopback
00:00:00:00:00:00brd00:00:00:00:00:00
inet127.0.0.1
/8
scopehostlo
valid_lftforeverpreferred_lftforever
inet6::1
/128
scopehost
valid_lftforeverpreferred_lftforever
2:eno16777736:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000
link
/ether
00:0c:29:ca:24:8ebrdff:ff:ff:ff:ff:ff
inet192.168.1.50
/24brd
192.168.1.255scopeglobaleno16777736
valid_lftforeverpreferred_lftforever
inet6fe80::20c:29ff:feca:248e
/64
scopelink
valid_lftforeverpreferred_lftforever
3:eno33554984:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000
link
/ether
00:0c:29:ca:24:98brdff:ff:ff:ff:ff:ff
inet1.1.1.50
/24brd
1.1.1.255scopeglobaldynamiceno33554984
valid_lft1573secpreferred_lft1573sec
inet6fe80::20c:29ff:feca:2498
/64
scopelink
valid_lftforeverpreferred_lftforever
------------------------------------
2. Configure the master configuration file
----------
2.1 configure the/etc/named. conf file
[root@dns~]#vim/etc/named.conf
//
//named.conf
//
//ProvidedbyRedHatbindpackagetoconfiguretheISCBINDnamed(8)DNS
//serverasacachingonlynameserver(asalocalhostDNSresolveronly).
//
//See/usr/share/doc/bind*/sample/forexamplenamedconfigurationfiles.
//
options{
//listen-onport53{127.0.0.1;};
//listen-on-v6port53{::1;};
directory
"/var/named"
;
dump-file
"/var/named/data/cache_dump.db"
;
statistics-file
"/var/named/data/named_stats.txt"
;
memstatistics-file
"/var/named/data/named_mem_stats.txt"
;
allow-query{any;};
/*
-IfyouarebuildinganAUTHORITATIVEDNSserver,doNOTenablerecursion.
-IfyouarebuildingaRECURSIVE(caching)DNSserver,youneedtoenable
recursion.
-IfyourrecursiveDNSserverhasapublicIPaddress,youMUSTenableaccess
controltolimitqueriestoyourlegitimateusers.Failingtodosowill
causeyourservertobecomepartoflargescaleDNSamplification
attacks.ImplementingBCP38withinyournetworkwouldgreatly
reducesuchattacksurface
*/
recursionyes;
//dnssec-enableyes;
//dnssec-validationyes;
//dnssec-lookasideauto;
/*PathtoISCDLVkey*/
//bindkeys-file"/etc/named.iscdlv.key";
//managed-keys-directory"/var/named/dynamic";
pid-file
"/run/named/named.pid"
;
//session-keyfile"/run/named/session.key";
};
logging{
channeldefault_debug{
file
"data/named.run"
;
severitydynamic;
};
};
include
"/etc/named.rfc1912.zones"
;
//include"/etc/named.root.key";
----------
2. Configure the/etc/named. rfc1912.zones File
[root@dns~]#vim/etc/named.rfc1912.zones
//named.rfc1912.zones:
//
//ProvidedbyRedHatcaching-nameserverpackage
//
//ISCBINDnamedzoneconfigurationforzonesrecommendedby
//RFC1912section4.1:localhostTLDsandaddresszones
//andhttp://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
//(c)2007RWFranks
//
//See/usr/share/doc/bind*/sample/forexamplenamedconfigurationfiles.
//
viewwang_tong{
match-clients{1.1.1.0/24;};
zone
"."
IN{
typehint;
file
"named.ca"
;
};
zone
"localhost.localdomain"
IN{
typemaster;
file
"named.localhost"
;
allow-update{none;};
};
zone
"localhost"
IN{
typemaster;
file
"named.localhost"
;
allow-update{none;};
};
zone
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa"
IN{
typemaster;
file
"named.loopback"
;
allow-update{none;};
};
zone
"1.0.0.127.in-addr.arpa"
IN{
typemaster;
file
"named.loopback"
;
allow-update{none;};
};
zone
"0.in-addr.arpa"
IN{
typemaster;
file
"named.empty"
;
allow-update{none;};
};
zone
"zrd.com"
IN{
typemaster;
file
"zrd.com.wang_tong"
;
};
};
viewdian_xin{
match-clients{192.168.1.0/24;};
zone
"zrd.com"
IN{
typemaster;
file
"zrd.com.dian_xin"
;
};
};
view
default
{
match-clients{any;};
zone
"zrd.com"
IN{
typemaster;
file
"zrd.com.dian_xin"
;
};
};
------------------------------------
3. Configure the region File
---------
3. 1. Create the zrd.com. dian_xin region File
[root@dns~]#cd/var/named/
[root@dnsnamed]#vimzrd.com.dian_xin
$TTL86400
@INSOAdns.zrd.com.admin.zrd.com.(
2015092021
1D
2D
1D
7D
)
INNSdns
INMX10mail
wwwINA192.168.1.11
dnsINA192.168.1.50
mailINA192.168.1.12
-----
3. 2. Create the zrd.com. wang_tong File
[root@dnsnamed]#vimzrd.com.wang_tong
$TTL86400
@INSOAdns.zrd.com.admin.zrd.com.(
2015092021
1D
2D
1D
7D
)
INNSdns
INMX10mail
wwwINA1.1.1.11
dnsINA1.1.1.50
mailINA1.1.1.12
----
3. Modify file attributes
[root@dnsnamed]
#chownroot:namedzrd.com.wang_tongzrd.com.dian_xin
------------------------------------
4. Start the service and Test
-----
4. 1. Start the service
[root@dns~]
#systemctlstartnamed
----
4. 2. View service status
----
4. 3. Test
-----------------------