Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Closed TopicStart new topic
> Dhcp (dynamicdns,failover), CentOS 4.0
Robert83
post Apr 14 2005, 04:14 AM
Post #1


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi , in this guide I will show you how to configure DHCP to dynamicaly update BIND, and to setup 2 dhcp servers in failover mode.

In this example we have the following subnets (gw,dns,domain name)
subnet : 192.168.0.0/255.255.255.0 192.168.0.250 192.168.0.250 company1
subnet : 192.168.1.0/255.255.255.0 192.168.1.250 192.168.1.250 company2
subnet : 192.168.2.0/255.255.255.0 192.168.2.250 192.168.2.250 company3
subnet : 192.168.11.0/255.255.255.0 192.168.11.250 192.168.11.250 temporary (virtual interface)
192.168.10.2 Squid/Time-Server/Router (only for the detail)


----------------------------------------------------------------
Creating the Master DHCP server
----------------------------------------------------------------


Details :
Ip Address 192.168.1.200 / 255.255.255.0
Gw / DNS : 192.168.1.250 / 192.168.1.250

Install CentOS 4.0 using minimal install.

then do the following
CODE
cd /home
wget http://mirror.centos.org/centos/4/os/i386/RPM-GPG-KEY-CentOS-4
rpm --import RPM-GPG-KEY-CentOS-4
rm -f *
yum update
yum install dhcp


create the following two files in /etc
CODE
touch dhcpd.conf
touch dhcpd.master
chmod 644 dhcpd.*

warrning chmod 644 dhcpd.* , I've installed CentOS 4.0 and there was not other file in /etc which began with dhcpd so this should be safe to use, if there are some other file with dhcpd (not likely) then those to will be set to 644 rw r r root.root (since we are doing this as root)

in dhcpd.conf we type in the following

CODE
#
# G L O B A L   S E T T I N G S
#
ddns-update-style interim;
ddns-updates on;
update-static-leases on;
authoritative;
option ntp-servers 192.168.10.2;
option netbios-node-type 8;

#
# F A I L O V E R   P E E R
#

failover peer "dhcp" {
  primary;
  address 192.168.1.250;
  port 519;
  peer address 192.168.0.200;
  peer port 520;
  max-response-delay 60;
  max-unacked-updates 10;
  mclt 600;
  split 128;
  load balance max seconds 3;
}

#
# C L I E N T S
#

include "/etc/dhcpd.master";



----------------------------------------------------------------
Creating the Slave DHCP server
----------------------------------------------------------------

Details :
Ip Address 192.168.0.200 / 255.255.255.0
Gw / DNS : 192.168.0.250 / 192.168.0.250

in dhcpd.conf we type in the following

CODE
#
# G L O B A L   S E T T I N G S
#
ddns-update-style interim;
ddns-updates on;
update-static-leases on;
authoritative;
option ntp-servers 192.168.10.2;
option netbios-node-type 8;

#
# F A I L O V E R   P E E R
#

failover peer "dhcp" {
  secondary;
  address 192.168.0.200;
  port 520;
  peer address 192.168.1.200;
  peer port 519;
  max-response-delay 60;
  max-unacked-updates 10;
  }

#
# C L I E N T S
#

include "/etc/dhcpd.master";



----------------------------------------------------------------
Creating the dhcpd.master file , same for MASTER and SLAVE
----------------------------------------------------------------

CODE
shared-network city_name {

#
# S U B N E T  D E C L A R A T I O N
#

subnet 192.168.0.0 netmask 255.255.255.0 {
     ddns-domainname "company1";
     ddns-rev-domainname "in-addr.arpa";
     default-lease-time 86400;
     max-lease-time 86400;
     option broadcast-address 192.168.0.255;
     option routers 192.168.0.250;
     option domain-name-servers 192.168.0.250;
     option netbios-name-servers 192.168.0.200;
     zone company1. { primary 192.168.0.250;}
     zone 0.168.192.in-addr.arpa. { primary 192.168.0.250;}
}

subnet 192.168.1.0 netmask 255.255.255.0 {
     ddns-domainname "company2";
     ddns-rev-domainname "in-addr.arpa";
     default-lease-time 86400;
     max-lease-time 86400;
     option broadcast-address 192.168.1.255;
     option routers 192.168.1.250;
     option domain-name-servers 192.168.1.250;
     option netbios-name-servers 192.168.1.200;
     zone company2. { primary 192.168.1.250;}
     zone 1.168.192.in-addr.arpa. { primary 192.168.1.250;}
}

subnet 192.168.2.0 netmask 255.255.255.0 {
     ddns-domainname "company3";
     ddns-rev-domainname "in-addr.arpa";
     default-lease-time 86400;
     max-lease-time 86400;
     option broadcast-address 192.168.2.255;
     option routers 192.168.2.250;
     option domain-name-servers 192.168.2.250;
     option netbios-name-servers 192.168.2.200;
     zone company3. { primary 192.168.2.250;}
     zone 2.168.192.in-addr.arpa. { primary 192.168.2.250;}
}

#
# V I R T U A L
#

subnet 192.168.11.0 netmask 255.255.255.0 {
     ddns-domainname "temporary";
     ddns-rev-domainname "in-addr.arpa";
     default-lease-time 5400;
     max-lease-time 5400;
     option broadcast-address 192.168.11.255;
     option routers 192.168.11.250;
     option domain-name-servers 192.168.11.250;
     option netbios-name-servers 192.168.11.200;
     pool {
            failover peer "dhcp";
            range 192.168.11.100 192.168.11.200;
            deny dynamic bootp clients;
     }
     zone temporary. { primary 192.168.11.250;}
     zone 11.168.192.in-addr.arpa. { primary 192.168.11.250;}
}

#
# COMPANY1
#

host computer1 {
      hardware ethernet xx:xx:xx:xx:xx:xx;
      fixed-address 192.168.0.10;
}

#
# COMPANY2
#

host computer2 {
      hardware ethernet xx:xx:xx:xx:xx:xx;
      fixed-address 192.168.1.10;
}

#
# COMPANY3
#

host computer3 {
      hardware ethernet xx:xx:xx:xx:xx:xx;
      fixed-address 192.168.2.10;
}

}


----------------------------------------------------------------
Creating the DNS server
----------------------------------------------------------------

For me this DNS server is on the router , so it listens on
192.168.0.250
192.168.1.250
192.168.2.250
192.168.11.250

Install a minimal CentOS 4.0 here.
CODE
cd /home
wget http://mirror.centos.org/centos/4/os/i386/RPM-GPG-KEY-CentOS-4
rpm --import RPM-GPG-KEY-CentOS-4
rm -f *
yum update
yum install bind


I will only include the parts you need to add / modify in /etc/named.conf

CODE
#---------------------------------------
# My Network
#---------------------------------------

acl mynet {
                192.168.0.0/24;
                192.168.1.0/24;
                192.168.2.0/24;
                192.168.11.0/24;
                127.0.0.1;
};

options {
             listen-on-v6 { any; };
             notify no;
             forward only;
             forwarders {
                   62.108.117.6;
             };
             auth-nxdomain yes;
             listen-on {
                            mynet;
                          };
};

#---------------------------------------
# company1
#---------------------------------------

zone "company1" IN {
        type master;
        file "/var/named/company1/db.company1";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };

zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "/var/named/comapny1/db.0.168.192";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };

#---------------------------------------
# company2
#---------------------------------------

zone "company2" IN {
        type master;
        file "/var/named/company2/db.company2";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };

zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "/var/named/comapny2/db.1.168.192";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };

#---------------------------------------
# company3
#---------------------------------------

zone "company3" IN {
        type master;
        file "/var/named/company3/db.company3";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };

zone "2.168.192.in-addr.arpa" IN {
        type master;
        file "/var/named/comapny3/db.2.168.192";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };

#---------------------------------------
# temporary
#---------------------------------------

zone "temporary" IN {
        type master;
        file "/var/named/temporary/db.temporary";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };

zone "11.168.192.in-addr.arpa" IN {
        type master;
        file "/var/named/temporary/db.11.168.192";
        allow-update { mynet; };
        allow-query   { mynet; };
        allow-transfer { mynet; };
        };


Now under war named create the following directories,
CODE
cd /var/named
mkdir {company1,company2,company3,temporary}
chmod 775 company1 company2 company3 temporary
chown root.named company1 company2 company3 temporary


Okay, now lets create the db files for the zones.

/var/named/company1/db.company1

CODE
;
; BIND data file for company1
;
$TTL   86400
@       IN          SOA        saruman.company1.   root.company1. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
@       IN        NS    saruman.company1.
;-------------------------------------------------------------;
saruman     IN   A    192.168.10.2                                         ;
sam           IN   A    192.168.0.200                                       ;
;-------------------------------------------------------------;
;end.


/var/named/company1/db.0.168.192

CODE
;
; BIND data file for 192.168.0.x reverse DNS
;
$TTL   86400
@       IN          SOA        saruman.company1.   root.company1. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
;
@           IN      NS         saruman.company1.
;
200         IN      PTR       saruman.company1.
;end



/var/named/company2/db.company2

CODE
;
; BIND data file for company2
;
$TTL   86400
@       IN          SOA        saruman.company2.   root.company2. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
@       IN        NS    saruman.company2.
;-------------------------------------------------------------;
saruman     IN   A    192.168.10.2                                         ;
sam           IN   A    192.168.1.200                                       ;
;-------------------------------------------------------------;
;end.


/var/named/company2/db.0.168.192

CODE
;
; BIND data file for 192.168.1.x reverse DNS
;
$TTL   86400
@       IN          SOA        saruman.company2.   root.company2. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
;
@           IN      NS         saruman.company2.
;
200         IN      PTR       saruman.company2.
;end



/var/named/company3/db.company3

CODE
;
; BIND data file for company3
;
$TTL   86400
@       IN          SOA        saruman.company3.   root.company3. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
@       IN        NS    saruman.company3.
;-------------------------------------------------------------;
saruman     IN   A    192.168.10.2                                         ;
;-------------------------------------------------------------;
;end.


/var/named/company3/db.0.168.192

CODE
;
; BIND data file for 192.168.2.x reverse DNS
;
$TTL   86400
@       IN          SOA        saruman.company3.   root.company3. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
;
@           IN      NS         saruman.company3.
;end



/var/named/temporary/db.temporary

CODE
;
; BIND data file for temporary
;
$TTL   86400
@       IN          SOA        saruman.temporary.   root.temporary. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
@       IN        NS    saruman.temporary.
;-------------------------------------------------------------;
saruman     IN   A    192.168.10.2                                         ;
;-------------------------------------------------------------;
;end.


/var/named/temporary/db.11.168.192

CODE
;
; BIND data file for 192.168.11.x reverse DNS
;
$TTL   86400
@       IN          SOA        saruman.temporary.   root.temporary. (
              2005040910    ; serial
                      28800    ; refresh
                        7200    ; retry
                     604800   ; expire
                      86400    ; negative cache ttl
            )
;
@           IN      NS         saruman.temporary.
;
200         IN      PTR       saruman.temporary.
;end


once done with typing all this stuff in.
CODE
chkconfig named on
/etc/init.d/named start

then turn on the dhcp servers
for example

CODE
ssh 192.168.1.200
chkconfig dhcpd on
/etc/init.d/dhcpd start
logout
ssh 192.168.0.200
chkconfig dhcpd on
/etc/init.d/dhcpd start
logout


Aditionaly if you are using samba now you can set the following to yes.
CODE
dns proxy = Yes

according to the samba manual, if samba is not able to find a host in wins database
it will lookup the host in the dns.

From now on when a client gets a ip address via dhcp it automaticaly registeres itself
in DNS.

For example computer1 goes online it registers itself with dns server , and depending on what company it belongs to (in this example lets say company1)

you'll be able to ping it like this
CODE
ping computer1.company1


Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th December 2017 - 04:08 AM