Configure Dynamic DNS(DDNS) CentOS

Configure Dynamic DNS(DDNS) CentOS

Configure Dynamic DNS(DDNS) CentOS

Dynamic DNS allows you to dynamically update your zone files, without needing to restart the BIND/Named service, as well as immediately pushes changes to slaves. This is a wonderful enhancement of the BIND package, and should be the default and prefered way to deploy DNS both internally, and publicly.

our DNS domain we are going to setup will be called “test.local” you can choose what you want

Login and su to root

Root shell prompt on host ddnsmaster

the first thing we need to do is install the BIND packages

yum -y install bind bind-utils bind-chroot

configure bind/DNS to run on startup

chkconfig named on and service named start, Generating /etc/rndc.key OK, Starting named OK

now modify the /etc/resolv.conf to reflect the local server, ip, or localhost (your environment may have specific requirements)

/etc/resolv.conf, search test.local, nameserver 127.0.0.1 and nameserver ip-of-server

now we need to re-generate the dynamic dns key

Same /etc/resolv.conf screenshot repeated at the step to re-generate the dynamic DNS key

now we need to add it to the /etc/named.conf on line 44

named.conf lines 42-44 including /etc/named.rfc1912.zones, /etc/named.root.key and /etc/rndc.key

add lines 46 and 47, that way localhost can get status of the named service

named.conf controls block, inet 127.0.0.1 allow localhost keys rndc-key

for ipv4, add the local network if internal, or any if external dns, you can choose to configure ipv6, or comment it out if you do not use it. Replace 192.168.1.x with your network, or any

named.conf options, listen-on port 53 for 192.168.1.x, listen-on-v6 commented out

lines 17 you want to allow query, you can put your network or any.

** LINE 18 – you want this set to yes if it’s an internal dns server, and NO if it’s external, that way you don’t get DDoS Attacks.

named.conf allow-query 192.168.1.x and recursion yes

now we need to specify DNS forwarders for queries that cannot be resolved by the local server(s)

named.conf forwarders block, this-servers-ip, 8.8.8.8 and 8.8.4.4

make sure you have the local server’s IP, otherwise dynamic DNS will not work, also include google’s DNS servers, they can resolve anything yours cannot.

also add the max journal size, these can get quite large over time

named.conf max-journal-size 5M;

from here we need to set the proper permissions on the rndc.key

chown root:named /etc/rndc.key and chmod 644 /etc/rndc.key

restart bind to make sure your configuration is correct

service named restart, Stopping named OK, Starting named OK

let’s create our zone files. cd /var/named/dynamic, and copy from the blank zones, as you can see, we made both forward and reverse DNS zones

cp ../named.empty test.local and cp ../named.empty 192.168.1.rev in /var/named/dynamic

modfiy the forward zone to look as follows, don’t forget to set the serial to 1:

Forward zone test.local, SOA ddnsmaster.test.local with serial 1, NS and A records for your-server-ip

modify the reverse zone to look as follows, don’t forget to set the serial to 1:

Reverse zone 1.168.192.in-addr.arpa, SOA with serial 1 and NS ddnsmaster.test.local

change ownership of your DNS zone files to named

chown named:named test.local 192.168.1.rev, then ls -l of /var/named/dynamic

now create the forward/reverse zones in /etc/named.conf

named.conf zones test.local and 1.168.192.in-addr.arpa, type master, allow-update key rndc-key

** If External, you want to additionally specify where you want to allow zone transfers to slave servers

 allow-transfer {
                slave-server-ip;
                };

restart bind again to make sure it picks up your new zone files

service named restart in /var/named/dynamic to load the new zones

now we need to make bind able to write to the dynamic folder

chmod 770 /var/named/ so named can write to the dynamic folder

DNS Update with nsupdate:

Let’s verify dynamic DNS works, cd to /tmp

vi test.txt in /tmp to write the nsupdate commands

we are going to add an A record, and a PTR, basically forward and reverse DNS for an address

test.txt, update add test1.test.local 3600 A 192.168.1.100, send, then the PTR record and send

save and close

issue the following command to send the DNS changes to DNS:

Same test.txt nsupdate contents shown at the step that sends the update

now let’s verify it worked, tail /var/log/messages

/var/log/messages, signer rndc-key approved, updating zone test.local/IN and 1.168.192.in-addr.arpa/IN

you should see something like “rndc-key approved, and “updating zone” for your forward/reverse.

use nslookup/dig to verify dns in fact did update

nslookup test1 returns 192.168.1.100 and nslookup 192.168.1.100 returns test1.test.local

success! You have successfully configured dynamic dns!

  • For other Dynamic DNS updates, take a look at the nsupdate cheat sheet
  • To configure a Dynamic DNS Slave Server, click here
  • To configure DHCP with Dynamic DNS click here

Hosted Linux Servers at www.zwiegnet.com/go

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *