Create a DHCP and DNS server with RedHat/ CentOS Linux

#yum -y install bind bind-utils dhcp

 

Tell what interface to use with dhcpd:   /etc/sysconfig/dhcpd

DHCPDARGS=eth2

 

In /etc/named.conf add: (Modify to suit the following)

allow-query     { any; };

allow-recursion {any; };

listen-on port 53 { 10.10.10.2; };

 

Add this zone near the bottom:

 

zone “dhcpserver” IN {

type master;

file “dhcpserver”;

allow-update { any; };

notify no;

};

 

Create /var/named/dhcpserver:

 

@       IN      SOA     dhcpserver. hostmaster.dhcpserver. (

2012080701      ; Serial

43200      ; Refresh

3600       ; Retry

3600000    ; Expire

2592000 )  ; Minimum

;       Define the nameservers and the mail servers

IN      NS      dhcpserver.

IN      A       10.10.10.2

ns            IN      A       10.10.10.2

www        IN      A       10.10.10.2

client        IN      A       10.10.10.3

gateway        IN      A       10.10.10.2

 

Only have this in /etc/dhcp/dhcpd.conf:

 

subnet 10.10.10.0 netmask 255.255.255.0 {

option routers                  10.10.10.2;

option subnet-mask              255.255.255.0;

option domain-name              “dhcpserver”;

option domain-name-servers       10.10.10.2;

option time-offset              -18000;     # Eastern Standard Time

range 10.10.10.20 10.10.10.30;

}

 

#chkconfig named on

#chkconfig dhcpd on

#service named start

#service dhcpd start

CentOSlinuxRedHat