DDNS & DHCPD CENTOS 6.5

Installing Packages

# yum install bind* -y

Install dhcpd

# yum install dhcp –y

 

Configuring BIND

Edit the file /etc/named.conf

Add the following lines

++++++++++++++++++++++++++++++++++++++++++++++++++++

options {

listen-on port 53 { 192.168.3.1; }; # You also can listen in all network interfaces or only on the interface connected to your LAN

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 { localhost; 192.168.3.0/24; };
# you can allow everybody or only an specific subnet

recursion yes;

forwarders { 216.19.176.6; 216.19.176.7; 8.8.8.8; }; # add the DNSs you want

logging {

channel default_debug {

file “data/named.run”;

severity dynamic;

};

};

#Zones

zone “.” IN {

type hint;

file “named.ca”;

};

zone “mrobp.com” IN {

# Add the name of the domain in my case is mrobp.com


type master;

file “dynamic/db.mrobp.com”;
#Add the name of the file under the directory /var/named/dynamic

allow-update { key rndc-key; };
# This is the Key that Allow update the DNS records


notify yes;

};

zone “3.168.192.in-addr.arpa” {
# This line will help you to add reverse records on your DNS-server

type master;

file “dynamic/db.192.168.3”;

allow-update { key rndc-key; };
# This is the Key that Allow update the DNS records

notify yes;

};

include “/etc/named.rfc1912.zones”;

include “/etc/named.root.key”;

include “/etc/rndc.key”;
# This is the location of the rndc.key

++++++++++++++++++++++++++++++++++++++++++++++++++++

#Generating the RNDC.KEY

# rndc-confgen –a
# This command will generate the rndc under the directory /etc

NOTE: make sure to secure the file. It is very important change permissions to “chmod 640” will be suffice

Now we have to create the files under the directory /var/named

# cd /var/named/dynamic

# touch db.mrobp.com

# touch db.192.168.3

Open the first file db.mrobp.com add the following lines

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

$ORIGIN .

$TTL 604800 ; 1 week

mrobp.com IN SOA monitor.mrobp.com. odin_blanco\@mrobp.com. (

2014122005 ; serial

10800 ; refresh (3 hours)

3600 ; retry (1 hour)

604800 ; expire (1 week)

86400 ; minimum (1 day)

)

NS monitor.mrobp.com.

$ORIGIN mrobp.com.

monitor A 192.168.3.1

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

Open the second File db.192.168.3

Add the following lines

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

$ORIGIN .

$TTL 604800 ; 1 week

mrobp.com IN SOA monitor.mrobp.com. odin_blanco\@mrobp.com. (

2014122005 ; serial

10800 ; refresh (3 hours)

3600 ; retry (1 hour)

604800 ; expire (1 week)

86400 ; minimum (1 day)

)

3.168.192.in-addr.arpa. IN NS monitor.mrobp.com.

1 IN PTR monitor.mrobp.com.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Start service

# service named start
# Verify that there are not errors reported

# ps –fea |grep named
# should be running

Configuring DHCPD

Edit the file /etc/dhcp/dhcpd.conf

Add the following lines

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#Dynamic DNS

ddns-update-style interim;

ddns-updates on;

key rndc-key {

algorithm hmac-md5;

secret “GlKi5/l0r43N+OXeOmQ==”;#copy your rndc.key

};

#from BOOT

allow booting;

allow bootp;

athoritative;

ignore client-updates;

#options

option domain-name-servers monitor.mrobp.com;

option domain-name “mrobp.com”;

default-lease-time 600;

max-lease-time 7200;

log-facility local7;

#subnet

subnet 192.168.3.0 netmask 255.255.255.0 {

range 192.168.3.100 192.168.3.200;

option domain-name-servers monitor.mrobp.com;

option domain-name “mrobp.com”;

option routers 192.168.3.1;

option broadcast-address 192.168.3.255;

default-lease-time 600;

max-lease-time 7200;

filename “undionly.cfg”; # for iPXE

next-server 192.168.1.1; # server running TFTP

}

#zones for DNS

 

zone mrobp.com.{

primary 192.168.3.1;

key rndc-key;

}

 

zone 3.168.192.in-addr.arpa. {

primary 192.168.3.1;

key rndc-key;

}

Check your logs, you should see something like these lines

# tail -f /var/log/messages

client 192.168.3.1#56715: updating zone ‘mrobp.com/IN’: adding an RR at ‘zfsbsd.mrobp.com’ A

Dec 20 23:37:04 monitor dhcpd: Added new forward map from zfsbsd.mrobp.com to 192.168.3.106

Dec 20 23:37:04 monitor named[3146]: client 192.168.3.1#55972: signer “rndc-key” approved

Dec 20 23:37:04 monitor named[3146]: client 192.168.3.1#55972: updating zone ‘3.168.192.in-addr.arpa/IN’: deleting rrset at ‘106.3.168.192.in-addr.arpa’ PTR

Dec 20 23:37:04 monitor named[3146]: client 192.168.3.1#55972: updating zone ‘3.168.192.in-addr.arpa/IN’: adding an RR at ‘106.3.168.192.in-addr.arpa’ PTR

Dec 20 23:37:04 monitor dhcpd: added reverse map from 106.3.168.192.in-addr.arpa. to zfsbsd.mrobp.com

References 

https://www.centos.org/docs/5/html/Deployment_Guide-en-US/index.html