SETTING UP DYNAMIC DNS AND DHCP ON OPENBSD
The
purpose of this tutorial is to create a DNS + DHCP machine where the DNS is
Automatically updated according to the IP allocated by the DHCP.
DNS Server
The following “named.conf” consist only the two zone files which has to be updated according to the DHCP allotment, one can also have many other zone files which are static not to be updated dynamically and has different domain names according to his/her suitability.
Putting the following to the /var/named/etc/named.conf
========================START=================================
// $OpenBSD: named-simple.conf,v 1.10 2009/11/02 21:12:56 jakob Exp $
//
// Example file for a simple named configuration, processing both
// recursive and authoritative queries using one cache.
// Update this list to include only the networks for which you want
// to execute recursive queries. The default setting allows all hosts
// on any IPv4 networks for which the system has an interface, and
// the IPv6 localhost address.
//
acl clients {
localnets;
::1;
};
options {
version ""; // remove this to allow version queries
listen-on { any; };
listen-on-v6 { any; };
empty-zones-enable yes;
allow-recursion { clients; };
};
logging {
category lame-servers { null; };
};
// Standard zones
//
zone "." {
type hint;
file "etc/root.hint";
};
zone "localhost" {
type master;
file "standard/localhost";
allow-transfer { localhost; };
};
zone "127.in-addr.arpa" {
type master;
file "standard/loopback";
allow-transfer { localhost; };
};
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" {
type master;
file "standard/loopback6.arpa";
allow-transfer { localhost; };
};
###This is the key which we copied earlier also pasted here
key "rndc-key" {
algorithm hmac-md5;
secret "4XS+kgobLMI3WmmLWgmMsQ==";
};
zone " example.com" IN {
type master;
file "master/ example.com.zone";
notify yes;
allow-update { key "rndc-key";};
};
zone "8.168.192.in-addr.arpa" IN {
type master;
file "master/8.168.192.zone";
notify yes;
allow-update { key "rndc-key"; };
};
================================END============================
the following in /var/named/master/example.com.zone
========================START=================================
$ORIGIN .
$TTL 86400 ; 1 day
example.com IN SOA example.com. root. example.com. (
2013034708 ; serial
10800 ; refresh (3 hours)
3600 ; retry (1 hour)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS ns1.example.com.
$ORIGIN example.com.
$TTL 3600 ; 1 hour
================================END============================
the following in /var/named/master/8.168.192.zone
========================START=================================
ORIGIN .
$TTL 86400 ; 1 day
8.168.192.in-addr.arpa IN SOA example.com. root.example.com. (
2013032774 ; serial
10800 ; refresh (3 hours)
3600 ; retry (1 hour)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS ns1.example.com.
$ORIGIN 8.168.192.in-addr.arpa.
$TTL 3600 ; 1 hour
================================END============================
In the last changing the ownership of NAMED directory
#chown –R named:named /var/named/
And making dhcpd and named run on start up
Open /etc/rc.conf and search
dhcpd_flags=NO
to
dhcpd_flags=""
and
named_flags=NO
to
named_flags=""
DHCP Server
For the following purpose first we have to install the ISC-DHCP and remove the default shipped DHCP, as it does not have the feature to implement the Automatic DNS updation.
Package adding
Now replacing the executable
Run the following commands
#cd /sbin
#mkdir isc-dhcp-2.0
#mv dhclient isc-dhcp-2.0/
#mv dhclient-script isc-dhcp-2.0/
#mv /usr/local/sbin/dhclient-script dhclient-script
#mv /usr/local/sbin/dhclient dhclient
#cd /usr/sbin
#mkdir isc-dhcp-2.0
#mv dhcpd isc-dhcp-2.0/
#mv /usr/local/sbin/dhcpd dhcpd
#mv dhcrelay isc-dhcp-2.0/
#mv /usr/local/sbin/dhcrelay dhcrelay
#cd /usr/bin
#mv /usr/local/bin/omshell omshell
#cd /etc
#mkdir isc-dhcp-2.0
#mv dhclient.conf isc-dhcp-2.0/
#mv dhcpd.conf isc-dhcp-2.0/
#cp /usr/local/share/examples/isc-dhcp/dhclient.conf dhclient.conf
#cp /usr/local/share/examples/isc-dhcp/dhcpd.conf dhcpd.conf
Note:- If some some the above commands gives error like “no such file” or similar don’t panic just follow and complete the process and if encountered any error, visit logs J.
Now generating the Key and copying it to /var/named/etc/rndc.key
#rndc-confgen
#less /etc/rndc.key
key "rndc-key" {
algorithm hmac-md5;
secret "4XS+kgobLMI3WmmLWgmMsQ==";
};
Copy the above key and then run
#cp /etc/rndc.key /var/named/etc/rndc.key
Configuring the dhcpd.conf
/etc/dhcpd.conf
####################START####################################
authoritative; # No other DHCP servers on this subnet
ddns-update-style interim; #Supported update method - see man
using ddns
ignore client-updates; # Overwrite client configured FQHNs
ddns-domainname "example.com.";
ddns-rev-domainname "in-addr.arpa.";
allow unknown-clients;
###This is the key which we copied earlier, pasted here.
key "rndc-key" {
algorithm hmac-md5;
secret "4XS+kgobLMI3WmmLWgmMsQ==";
};
zone example.com. { # Forward zone to be updated
primary 127.0.0.1;
key rndc-key;
}
zone 8.168.192.in-addr.arpa. { # Backward zone to be updated
primary 127.0.0.1;
key rndc-key;
}
option subnet-mask 255.255.255.0;
default-lease-time 172800;
max-lease-time 1209600;
shared-network example {
subnet 192.168.8.0 netmask 255.255.255.0 {
range 192.168.8.40 192.168.8.250;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.8.255;
option routers 192.168.8.1;
option domain-name "example.com";
option domain-name-servers 192.168.8.1;
}
}
#############################END##############################
Here the DHCP is configured for only single subnet hence one can increase the number of networks he/she wants to use according to his/her choice