Академический Документы
Профессиональный Документы
Культура Документы
Me nu
Co mmunit y
By:Mit chellAnicas
13
17
HowToConfigureBINDasaPrivateNetworkDNS
ServeronCentOS7
Apr29,2015
DNS,Net workingCent OS
Introduction
Animport ant part of managingserverconf igurat ionandinf rast ruct ureincludesmaint ainingan
easywayt olookupnet workint erf acesandIPaddressesbyname,byset t ingupaproper
DomainNameSyst em(DNS).Usingf ullyqualif ieddomainnames(FQDNs),inst eadof IP
addresses,t ospecif ynet workaddresseseasest heconf igurat ionof servicesand
applicat ions,andincreasest hemaint ainabilit yof conf igurat ionf iles.Set t ingupyourownDNS
f oryourprivat enet workisagreat wayt oimprovet hemanagement of yourservers.
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
1/29
3/10/16
Prerequisit es
T ocomplet et hist ut orial,youwillneedt hef ollowing:
If youareunf amiliarwit hDNSconcept s,it isrecommendedt hat youreadat least t hef irst
t hreepart sof ourInt roduct iont oManagingDNS.
ExampleHosts
Forexamplepurposes,wewillassumet hef ollowing:
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
2/29
3/10/16
"nyc3.example.com"t oref ert oourprivat esubnet orzone.T heref ore,ho st1'sprivat eFullyQualif iedDomainName(FQDN)willbe"host 1.nyc3.example.com".Ref ert ot hef ollowingt able
t herelevant det ails:
Ho st
Ro le
Privat eFQDN
Privat eIPAddress
host 1
GenericHost 1
host 1.nyc3.example.com
10.128.100.101
host 2
GenericHost 2
host 2.nyc3.example.com
10.128.200.102
usedt odemonst rat ehowt oconf igureaDNSservert oprovideaf unct ioningint ernalDNS.You
shouldbeablet oeasilyadapt t hisset upt oyourownenvironment byreplacingt hehost
namesandprivat eIPaddresseswit hyourown.It isnot necessaryt ouset heregionnameof
t hedat acent erinyournamingscheme,but weuseit heret odenot et hat t hesehost sbelong
t oapart iculardat acent er'sprivat enet work.If youut ilizemult ipledat acent ers,youcanset up
anint ernalDNSwit hineachrespect ivedat acent er.
OurGoal
Byt heendof t hist ut orial,wewillhaveaprimaryDNSserver,ns1,andopt ionallyasecondary
DNSserver,ns2,whichwillserveasabackup.
Ho st
Ro le
Privat eFQDN
Privat eIPAddress
ns1
PrimaryDNSServer
ns1.nyc3.example.com
10.128.10.11
ns2
SecondaryDNSServer
ns2.nyc3.example.com
10.128.20.12
Inst allBINDonDNSServers
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
3/29
3/10/16
No t e:T ext t hat ishighlight edinredisimport ant !It willof t enbeusedt odenot esomet hing
y.
Conf igurePrimaryDNSServer
BIND'sconf igurat ionconsist sof mult iplef iles,whichareincludedf romt hemainconf igurat ion
f ile,
processt hat BINDruns.Wewillst art wit hconf iguringt heopt ionsf ile.
Conf igureBind
BIND'sprocessisknownasnamed .Assuch,manyof t hef ilesref ert o"named"inst eadof
"BIND".
Onns1,opent he
$ sudo vi /etc/named.conf
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
4/29
3/10/16
acl "trusted" {
10.128.10.11;
10.128.20.12;
# ns2
10.128.100.101; # host1
10.128.200.102; # host2
};
optionsblock.Add
listen-on-v6line:
options {
listen-on port 53 { 127.0.0.1; 10.128.10.11; };
#
...
...
options {
...
allow-transfer { 10.128.20.12; };
default
...
allow-query { trusted; }; # allows queries from "trusted" clients
...
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
5/29
3/10/16
include "/etc/named/named.conf.local";
Nowsaveandexit
Conf igureLocalFile
Onns1,opent he
$ sudo vi /etc/named/named.conf.local
zone "nyc3.example.com" {
type master;
file "/etc/named/zones/db.nyc3.example.com"; # zone file path
};
zone "128.10.in-addr.arpa" {
type master;
file "/etc/named/zones/db.10.128"; # 10.128.0.0/16 subnet
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
6/29
3/10/16
};
named.conf.localf ile.
CreateForwardZoneFile
T hef orwardzonef ileiswherewedef ineDNSrecordsf orf orwardDNSlookups.T hat is,when
t heDNSreceivesanamequery,"host 1.nyc3.example.com"f orexample,it willlookint he
f orwardzonef ilet oresolveho st1'scorrespondingprivat eIPaddress.
/etc/named/zones:
$ sudo vi /etc/named/zones/db.nyc3.example.com
namedprocess- -
IN
SOA
ns1.nyc3.example.com. admin.nyc3.example.com. (
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
7/29
3/10/16
3
604800
; Serial
; Refresh
86400
; Retry
2419200
; Expire
604800 )
NS
ns1.nyc3.example.com.
IN
NS
ns2.nyc3.example.com.
IN
10.128.10.11
ns2.nyc3.example.com.
IN
10.128.20.12
host1.nyc3.example.com.
IN
10.128.100.101
host2.nyc3.example.com.
IN
10.128.200.102
; 10.128.0.0/16 - A records
Saveandexit t he
db.nyc3.example.comf ile.
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
8/29
3/10/16
1 $TTL
604800
2@
IN
SOA
ns1.nyc3.example.com. admin.nyc3.example.com. (
4
5
604800
86400
; Refresh
; Retry
2419200
; Expire
; Serial
604800 )
8;
9 ; name servers - NS records
10
IN
NS
ns1.nyc3.example.com.
11
IN
NS
ns2.nyc3.example.com.
12
13 ; name servers - A records
14 ns1.nyc3.example.com.
IN
10.128.10.11
15 ns2.nyc3.example.com.
IN
10.128.20.12
17 ; 10.128.0.0/16 - A records
18 host1.nyc3.example.com.
IN
10.128.100.101
19 host2.nyc3.example.com.
IN
10.128.200.102
16
CreateReverseZoneFile(s)
Reversezonef ilearewherewedef ineDNSPT Rrecordsf orreverseDNSlookups.T hat is,
whent heDNSreceivesaquerybyIPaddress,"10.128.100.101"f orexample,it willlookint he
reversezonef ile(s)t oresolvet hecorrespondingFQDN,"host 1.nyc3.example.com"int hiscase.
f ile.
named.conf.local:
$ sudo vi /etc/named/zones/db.10.128
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
9/29
3/10/16
namedprocess- -
IN
SOA
ns1.nyc3.example.com. admin.nyc3.example.com. (
3
604800
86400
2419200
604800 )
; Serial
; Refresh
; Retry
; Expire
; Negative Cache TTL
NS
ns1.nyc3.example.com.
IN
NS
ns2.nyc3.example.com.
T henadd
; PTR Records
11.10
IN
PTR
ns1.nyc3.example.com.
; 10.128.10.11
12.20
IN
PTR
ns2.nyc3.example.com.
; 10.128.20.12
101.100 IN
PTR
host1.nyc3.example.com. ; 10.128.100.101
102.200 IN
PTR
host2.nyc3.example.com. ; 10.128.200.102
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
10/29
3/10/16
1 $TTL
604800
2@
3
IN
SOA
nyc3.example.com. admin.nyc3.example.com. (
3
; Serial
604800
86400
6
7
2419200
604800 )
; Refresh
; Retry
; Expire
; Negative Cache TTL
8 ; name servers
9
IN
NS
ns1.nyc3.example.com.
10
11
IN
NS
ns2.nyc3.example.com.
12 ; PTR Records
13 11.10
IN
PTR
ns1.nyc3.example.com.
; 10.128.10.11
14 12.20
IN
PTR
ns2.nyc3.example.com.
; 10.128.20.12
15 101.100 IN
16 102.200 IN
PTR
PTR
host1.nyc3.example.com. ; 10.128.100.101
host2.nyc3.example.com. ; 10.128.200.102
CheckBINDConf igurationSyntax
Runt hef ollowingcommandt ocheckt hesynt axof t he
named.conf*f iles:
$ sudo named-checkconf
T he
named-checkconfagain.
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
11/29
3/10/16
named.conf.local.
StartBIND
St art BIND:
Conf igureSecondaryDNSServer
Inmost environment s,it isagoodideat oset upasecondaryDNSservert hat willrespondt o
request sif t heprimarybecomesunavailable.Luckily,t hesecondaryDNSserverismucheasier
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
12/29
3/10/16
t oconf igure.
Onns2,edit t he
named.conff ile:
$ sudo vi /etc/named.conf
named.conff ileand
acl "trusted" {
10.128.10.11;
10.128.20.12;
# ns2
10.128.100.101; # host1
10.128.200.102; # host2
};
optionsblock.Add
listen-on-v6line:
options {
listen-on port 53 { 127.0.0.1; 10.128.20.12; };
#
...
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
13/29
3/10/16
Change
...
options {
...
allow-query { trusted; }; # allows queries from "trusted" clients
...
include "/etc/named/named.conf.local";
Nowsaveandexit
Saveandexit
Nowedit t he
named.conf.
named.conf.localf ile:
mastersdirect ivewhich
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
14/29
3/10/16
1 zone "nyc3.example.com" {
2
3
type slave;
file "slaves/db.nyc3.example.com";
5 };
6
7 zone "128.10.in-addr.arpa" {
8
type slave;
file "slaves/db.10.128";
10
11 };
Nowsaveandexit
named.conf.local.
Runt hef ollowingcommandt ocheckt hevalidit yof yourconf igurat ionf iles:
$ sudo named-checkconf
Conf igureDNSClient s
Bef oreallof yourserversint he"t rust ed"ACLcanqueryyourDNSservers,youmust conf igure
eachof t hemt ousens1andns2asnameservers.T hisprocessvariesdependingonOS,but
f ormost Linuxdist ribut ionsit involvesaddingyournameserverst ot he
/etc/resolv.conf
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
15/29
3/10/16
f ile.
CentOSClients
OnCent OS,RedHat ,andFedoraLinuxVPS,simplyedit t he
resolv.conff ile:
$ sudo vi /etc/resolv.conf
/e tc/re so lv.co nf
UbuntuClients
email@example.com
OnUbunt uandDebianLinuxVPS,youcanedit t he
SignUp
headf ile,whichisprependedt o
resolv.confonboot :
S CR O LLT O T O P
$ sudo vi /etc/resolvconf/resolv.conf.d/head
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
16/29
3/10/16
Nowrun
$ sudo resolvconf -u
Test Client s
Use
ForwardLookup
Forexample,wecanperf ormaf orwardlookupt oret rievet heIPaddressof
ho st1.nyc3 .e xample .co mbyrunningt hef ollowingcommand:
$ nslookup host1
searchopt ionisset t o
Output:
Server:
10.128.10.11
Address:
10.128.10.11#53
Name:
host1.nyc3.example.com
Address: 10.128.100.101
ReverseLookup
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
17/29
3/10/16
$ nslookup 10.128.100.101
Output:
Server:
10.128.10.11
Address:
10.128.10.11#53
11.10.128.10.in-addr.arpa
name = host1.nyc3.example.com.
db.nyc3.example.comand db.10.128).
Maint ainingDNSRecords
Nowt hat youhaveaworkingint ernalDNS,youneedt omaint ainyourDNSrecordssot hey
accurat elyref lect yourserverenvironment .
AddingHosttoDNS
Wheneveryouaddahost t oyourenvironment (int hesamedat acent er),youwillwant t oaddit
t oDNS.Hereisalist of st epst hat youneedt ot ake:
PrimaryName se rve r
Forwardzonef ile:Addan"A"recordf ort henewhost ,increment t hevalueof "Serial"
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
18/29
3/10/16
named.conf.options)
T henreloadBIND:
Se condaryName se rve r
Addyournewhost 'sprivat eIPaddresst ot he"t rust ed"ACL(
named.conf.options)
T henreloadBIND:
T est using
nslookup
RemovingHostf romDNS
If youremoveahost f romyourenvironment orwant t ojust t akeit out of DNS,just removeall
t het hingst hat wereaddedwhenyouaddedt heservert oDNS(i.e.t hereverseof t hest eps
above).
Conclusion
Nowyoumayref ert oyourservers'privat enet workint erf acesbyname,rat hert hanbyIP
address.T hismakesconf igurat ionof servicesandapplicat ionseasierbecauseyounolonger
havet oremembert heprivat eIPaddresses,andt hef ileswillbeeasiert oreadandunderst and.
Also,nowyoucanchangeyourconf igurat ionst opoint t oanewserversinasingleplace,your
primaryDNSserver,inst eadof havingt oedit avariet yof dist ribut edconf igurat ionf iles,which
easesmaint enance.
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
19/29
3/10/16
Heart
13
Share
Subscribe
Aut hor:
Mit chellAnicas
SpinupanSSDcloudserverinunderaminute.
Simpleset up.Fullroot access.
St raight f orwardpricing.
DEPLOYSERVER
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
20/29
3/10/16
17Comments
Leaveacomment ...
Lo gge dinas:
C o m m e nt
uddhab May28,2015
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
21/29
3/10/16
IPAddress
ns1
192.168.0.11
ns2
192.168.0.12
Ho st
IPAddress
host 1
192.168.0.101
host 2
192.168.0.102
T henscanqueryit self .
192.168.0.11
Address:
192.168.0.11#53
Name:
ns2.mydomain.com
Address: 192.168.0.12
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
22/29
3/10/16
m anicas July7,2015
ronald8192 August9,2015
@ manicas
Ididset t heresolv.conf
search mydomain.com
nameserver 192.168.0.11
nameserver 192.168.0.12
m anicas August10,2015
T heot hert hingist hat youneedt oleaveint heexist ingnameserverst hat allowyourserver
t oresolveInt ernet addresses:
nameserver 8.8.8.8
nameserver 8.8.4.4
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
23/29
3/10/16
alpha July7,2015
DearMit chell,
First of all,T hankyouverymuchf oryourt ut orial.
Ihavef ollowallt hest epabovet oinst allandconf iguremyDNS- rDNSserver.However,my
domainnamecant f oundt heip.T heseverscant bef oundwhenIdigornslookupigot
dif f erent IP.Besidet hat ,myreverseDNSdoesn't work.
Ihopeyoucanhelpt of indasolut iont omyproblemLookingf orwardt ohearf romyou
m anicas July7,2015
alpha July8,2015
DearMit chellAnicas
First of all,t hankverymuchf oryourhelpandprompt reply.
Myserverishost edint hecloudsomewhereelse,asyoument ionint hereplyf orDNSservers
f ornameresolut ion(resolv.conf ).T hat f ilecont aint hef ollowing:
;generat edby/sbin/dhclient - script
nameserver110.7 4.128.7 2
nameserver110.7 4.128.7 1
andwhenIcomment t hoseIPsanddigmydomainit worksf ineinmyserver,whenIdigin
anot herPCorserverit givemeanot herIP.WhenIdelet et hoseIPsandPut myIPit worksf inein
myserverbut elsewereit doesn't work.T helast t hingif Irest art myserverit neit herworkinmy
servernoranot her.
HowcanIget solvet hiserror.
Onceagaint hankyouverymuchandlookingf orwardt ohearf romyou
m anicas July8,2015
I'mnot sureof what you'ret ryingt odo.T heusecasef ort hist ut orialist oprovidename
resolut iont oyourserverst hat areinapart icular(privat e)subnet .T henames/IPsshouldnot
resolvef romcomput ersout side.
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
24/29
3/10/16
s pravtek July25,2015
zone "nyc3.example.com" {
type slave;
file "db.nyc3.example.com";
masters { 10.128.10.11; }; # ns1 private IP
};
zone "128.10.in-addr.arpa" {
type slave;
file "db.10.128";
masters { 10.128.10.11; }; # ns1 private IP
};
zone "nyc3.example.com" {
type slave;
file "slaves/db.nyc3.example.com";
masters { 10.128.10.11; }; # ns1 private IP
};
zone "128.10.in-addr.arpa" {
type slave;
file "slaves/db.10.128";
masters { 10.128.10.11; }; # ns1 private IP
};
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
25/29
3/10/16
alphaop August19,2015
Iwillbepast ingt hecont ent of t heconf igurat ionf ilesbellowf oryout ohaveclearpict ur:
Af t ert heInst allat ionandconf igurat ionwhenIuset hedigcommandt henIgot t hef ollowing
digmast erdns.anisehq.com
;;ANSWERSECT ION:
mast erdns.anisehq.com.7 199INA110.7 4.133.89
;;Queryt ime:239msec
;;SERVER:192.168.101.4#53(192.168.101.4)
;;WHEN:WedAug1917 :47 :512015
;;MSGSIZErcvd:55
It seemsnot beencorrect
Af t ert heInst allat ionandconf igurat ionwhenIuset henslookupcommandt henIgot t he
f ollowing
nslookup110.7 4.133.89
Server:192.168.101.4
Address:192.168.101.4#53
nslookupmast erdns.anisehq.com
Server:192.168.101.4
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
26/29
3/10/16
Address:192.168.101.4#53
ns1.aims.myand
ns2.aims.my:
$ dig ns +short 133.74.110.in-addr.arpa
ns2.aims.my.
ns1.aims.my.
you'ret ryingt ouse.If t heyare,t hencanyoupost t hez onef ilet hat 89.133.7 4.110.inaddr.arpaappearsin?
alphakeita September7,2015
DearRespect ed,
It isabout amont hnowt ryingt oinst allandconf igureDNSandReverseDNSserverandupt o
nowIamst rugglingwit hit becauseIamanewbiz z init .
Iamf acingbellowerror
f oryourinf ormat ionIhavet woIPsPublicandPrivat e
WhenInslookupns1.anisehq.comlocally(DNSsevermachine)
nslookupns1.anisehq.com
Server:192.168.101.134
Address:192.168.101.134#53
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
27/29
3/10/16
Name:ns1.anisehq.com
Address:192.168.101.134(Privat eIPof mymachine)
nslookupns1.anisehq.com
Server:192.168.101.4
Address:192.168.101.4#53
it shownot hing
nslookupns1.anisehq.com
;;connect iont imeout ;noservercouldbereached
m anicas September21,2015
ekaaaaprillia8 September13,2015
visit myblogplease:)
ht t ps://goyangjibang.wordpress.com/2015/09/13/lab- 4- dns- bind- di- cent os- 7 - dengan- client windows- 7 - ult imat e/
t hankssir:)
s aeed November29,2015
m anicas November30,2015
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
28/29
3/10/16
Co mmunity
T uto rials
T e rms,Privacy,& Co pyright
Que stio ns
S e curity
Pro je cts
T ags
Re po rtaBug
RS S
Ge tPaidto Write
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
29/29