Installing required packages:

yum install -y bind bind-chroot bind-libs bind-utils caching-nameserver dhcp

Configuring DHCP server

rm -rf /etc/dhcpd.conf
mv /usr/share/doc/dhcp-*/dhcpd.conf.sample /etc/dhcpd.conf

My dhcp configuration is as follows:

vi /etc/dhcpd.conf
authoritative;              # No other DHCP servers on this subnet
ddns-update-style interim;  # Supported update method - see man dhcpd.conf
ignore client-updates;      # Overwrite client configured FQHNs
ddns-domainname "home.network.";
ddns-rev-domainname "in-addr.arpa.";
include "/var/named/chroot/etc/rndc.key";
zone home.network. {          # Forward zone to be updated
primary 127.0.0.1;
key rndckey;
}
zone 1.168.192.in-addr.arpa. { # Backward zone to be updated
primary 127.0.0.1;
key rndckey;
}
subnet 192.168.1.0 netmask 255.255.255.0 { # Here Specify your subnet
option routers  192.168.1.1; # Specify your router address
option subnet-mask      255.255.255.0; # Specify subnet mask
option domain-name      "home.network"; # Specify domain name
option domain-name-servers      192.168.1.1; # Specify domain name ip
option time-offset            19800;        # Indian Standard Time
range dynamic-bootp 192.168.1.50 192.168.1.254; # Specify address pool from which dhcp client can get ips
default-lease-time 21600; # Default leased time in sec
max-lease-time 43200; # Max leased time in sec
}

Changing permission of rndc.key

chmod 755 /var/named/chroot/etc/rndc.key

Configuring DNS Server
(Note : You can get the copy of name file in /usr/share/doc/bind-*/sample/etc)

My bind configuration is as follows:

vi /var/named/chroot/etc/named.conf
//sample named.conf
options {
query-source port 53;
directory "/var/named";
forwarders { 8.8.8.8; 8.8.4.4; };
};
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
include "/etc/rndc.key";
zone "." {
type hint;
file "named.ca";
};
zone "0.0.127.in-addr.arpa" {
type master;
file "named.local";
};
zone "home.network" {
type master;
file "home.network.zone";
allow-update { key "rndckey"; };
notify yes;
};
zone "1.168.192.in-addr.arpa" {
type master;
file "1.168.192.zone";
allow-update { key "rndckey"; };
notify yes;
};

Now we have to create sample zone files
Creating home.network.zone file

vi /var/named/chroot/var/named/home.network.zone
$TTL 86400
@ IN SOA home.network root.home.network (
20100616   ; serial in yyymmddxx
28800      ; refresh (8 hours)
14400      ; retry (4 hours)
3600000    ; expire (5 weeks 6 days 16 hours)
86400      ; minimum (1 day)
)
@    IN  NS  home.network.
@    IN  A  192.168.1.10
home.network. IN  A  192.168.1.10

Creating reverse lookup zone file

vi /var/named/chroot/var/named/1.168.192.zone
$TTL 86400
@ IN SOA home.network root.home.network (
20100616   ; serial in yyymmddxx
28800      ; refresh (8 hours)
14400      ; retry (4 hours)
3600000    ; expire (5 weeks 6 days 16 hours)
86400      ; minimum (1 day)
)
@    IN  NS  home.network.
10.1.168.192.in-addr.arpa.     IN  PTR  home.network.

Modifying host file

vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.10 home.network

Modifying resolv.conf

vi /etc/resolv.conf
nameserver 192.168.1.10

Now make shortcuts of these files in the /var/named directory with the same name

cd /var/named
ln -s /var/named/chroot/var/named/home.network.zone home.network.zone
ln -s /var/named/chroot/var/named/1.168.192.zone 1.168.192.zone

Creating soft link of named.conf file

ln -s /var/named/chroot/etc/named.conf /etc/named.conf

Changing permissions

chmod 770 /var/named/chroot/var/named
chmod 770 /var/named

Starting dhcp and bind

service dhcpd restart
service named restart

Starting both the services at system start-up

chkconfig --level 35 dhcpd on
chkconfig --level 35 named on

To troubleshoot, both see /var/log/messages file

tail -f /var/log/messages | grep dhcp
tail -f /var/log/messages | grep named
Dynamic DNS on CentOS

One thought on “Dynamic DNS on CentOS

Leave a Reply

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