How to Install and Configure DHCP Server on Centos or Other Clone of Linux

.

centos How to Install and Configure DHCP Server on Centos or Other Clone of LinuxDHCP Server on Centos or other clone of Linux. DHCP – Dynamic Host Configuration Protocol
For any administrator it is mandatory to have service like dhcp for seamless network operation, even though your network is of only few computers.

It helps your centrally manage dns servers & ip pool.

Many admins avoids using dhcp as ip keeps on changing if computer is out of network for a day or two. In that case you can have ip assigned for MAC address or have longer lease for ip address. By default max lease time is12 hrs. You can increase default &∓ max lease time. This will enable dhcp server to retain ip for specific host even if it is out of network.

Configuring dhcp service.
Install dhcp service

install the programs required for the DHCP server with this command:

yum install dhcp

copy sample config & make suitable changes for your network.

cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf

To configure a DHCP server we will modify the configuration file /etc/dhcpd.conf. DHCP also uses the file /var/lib/dhcp/dhcpd.leases to store the client lease database.

Help for DHCP
Help is available from the following man pages:

man dhcp-eval
man dhcpd.conf
man dhcpd.leases
man dhcpd
man dhcrelay

Next we need to configure the DHCP server. First we need to know some information that we are going to assign. We need to know:

a. The range of IP addresses we want to assign to our computers. I normally use the 192.168.x.x networks for my internal LANs. In our example, we will use 192.168.0.0/255.255.255.0 as our network (that is the network that starts with 192.168.0.1 and ends with 192.168.0.254). We will save IPs 192.168.0.1 to 192.168.0.50 for servers and static addresses. We will pick the addresses 192.168.0.51 to 192.168.0.100 to assign to computers via DHCP.

b. The IP address of the DNS server(s) we will use for name lookups for our clients that we assign with DHCP. In my case, I will use the DNS server that I have setup on IP address 192.168.0.2. (You can use your ISP’s DNS server if you don’t have one … see the ISP’s site for details. You can also build your own internal DNS server on this machine or another internal machine by following this guide.

c. The Default Gateway of the computers that we are going to serve. In our example, this will be the IP address 192.168.0.1, which has been setup as the default gateway for our internal network.

d. The length of the lease (default and maximum). This is very subjective. If you have more PCs than IP addresses to give out, you want this to be a short time (600 seconds). If you have more IPs to give out than PCs (most likely the case), you can use a larger number. Microsoft defaults to 3 days (259200 seconds) with their DHCP servers. RedHat recommends 12 hours (43200 seconds). I will go with the RedHat default of 43200 seconds for default length and 86400 seconds for maximum length.

e. If we have a WINS server setup on the network (microsoft or samba only), we would need to know it’s IP address. I have one, it is 192.168.0.2 (on the same machine as my DNS server).

f. We need a domain name to give out as well. If you are using real IP addresses, you can use a real domain name as well … in our case, we are using an internal network (192.168.0.x) behind a single IP address from an ISP, so we will use the fictitious domain name home.local. If you are using an internal IP network, don’t use a real external domain name, or you may not be able to talk to real PCs on that external network.

Now we have our information, so let’s configure the server by creating a text file named /etc/dhcpd.conf. The first line in the file must be the DNS update scheme. There are 2 choices, but only one that works reliably … so we will use that one smile.gif. Here is the first line:

ddns-update-style interim;

The second line is whether to allow the DHCP to update client info to a Dynamic DNS server. In our example, we are not going to try and update a Dynamic DNS via our DHCP server, so we will not allow client updates. Here is our line 2:

ignore client-updates;

The next section of our file will be the subnet section … we will define the network, and input the info we gathered above (see section 3 {a-f} above). Here is the subnet section:

subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1; #Default Gateway
option subnet-mask 255.255.255.0;
option domain-name “home.local”;
option domain-name-servers 192.168.0.2;
option netbios-name-servers 192.168.0.2; #WINS Server
range dynamic-bootp 192.168.0.51 192.168.0.100; #DHCP Range to assign
default-lease-time 43200;
max-lease-time 86400;
}

The easiest way to do is change only your ip address / network for your LAN.

This is the sample configuration file, run

vi /etc/dhcpd.conf

ddns-update-style interim;
ignore client-updates;

subnet 192.168.222.0 netmask 255.255.255.0 {

# — default gateway
option routers 192.168.222.1;
option subnet-mask 255.255.255.0;

option nis-domain “linuxreaders.com”;
option domain-name “linuxreaders.com”;
option domain-name-servers 192.168.222.1;

option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# — Selects point-to-point node (default is hybrid). Don’t change this unless
# — you understand Netbios very well
# option netbios-node-type 2;

range dynamic-bootp 192.168.222.128 192.168.222.254;
default-lease-time 21600;
max-lease-time 43200;

# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}

Start dhcp service.

/etc/init.d/dhcpd start

or

service dhcpd start

To make the dhcp server restart at boot time, issue the commands:

chkconfig --level 2345 dhcpd on
chkconfig --level 016 dhcpd off

Then check to make sure it is correct with the command:

chkconfig --list dhcpd

the output should be

dhcpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Reference∓/blockquote

 How to Install and Configure DHCP Server on Centos or Other Clone of Linux

About Frank Boros

Frank Boros has written 107 post in this blog.

Incoming search terms:

Be Sociable, Share!
  • more How to Install and Configure DHCP Server on Centos or Other Clone of Linux

    You can leave a response, or trackback from your own site.

    4 Responses to “How to Install and Configure DHCP Server on Centos or Other Clone of Linux”

    1. to domain name says:

      hi guys…

      hi guysI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well and i have start my own blog now, , thanks for your effort…

    2. i really got help to setup my dhcp service when i stucked on a bad point. it showed very easy and clear way to config dhcp on centos. Thanks mate, gr8 article..

    3. Thanks for sharing, I found this story, while looking for some free downloads and ran across this site, useful comments and great points made.

    4. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. it’s about to domain name|Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.

    Leave a Reply


    − 7 = zero

    Powered by WordPress | Designed by: best suv | Thanks to trucks, infiniti suv and toyota suv
    show
     
    close
    Email
    Print
    WP Socializer Aakash Web
    promotepoint's Profile on Ping.sg