Installing & configuring DHCP

Posted on

Installing dhcpd

Installing dchpd you can use the same way as installing other packages, there are 2 kind of dhcpd source, the RPM package, and the binary one. The RPM package comes  your RedHat CDs. Just type as follows:

$ cd /mnt/cdrom/Redhat/RPMS$ rpm -i dhcp-<version>.rpm 

 

when you have the binary one, you can copy the binary source to any directory you like as you want to work in. in this example we have already had the binary source in the /usr/local/src directory:

 

$ cd /usr/local/src$ gunzip dhcpd-<version>.tar.gz$ tar –vxf dhcpd-<version>.tar 

go to the directory where the dhcpd files are extracted. Usually it will extract as the subdirectory in your current working directory.

 

$ cd dhcpd$ ./configure –prefix = /usr/local/dhcpd 

This will use /usr/local/dhcpd as the home directory for dhcpd.

The two ways of installation, whether you use the rpm or binary package will install all files needed by the dhcp daemon to run. But before you can have the daemon to run well, you need to change some configuration in the /etc/dhcpd.conf file.


 

Configuring dhcpd

The main configuration file when setting up a dhcp server is /etc/dhcpd.conf. you will need to modify the file to suit your network infrastructure.

The time you installed dhcpd server, you might need to create the dhcpd.conf to your /etc/ directory, because it wasn’t there by default. You can use the dhcpd.conf.sample file at the minimum configuration as your simple dhcpd.conf file. Copy it to your /etc directory, and rename it with dhcpd.conf.

Be aware that you know that dhcpd and dhcpcd is different. Dhcpd is the server ( the program that serve as dhcp daemon), and in contrast dhcpcd is the client daemon.

$ find / |grep dhcpd.conf 

 

when you first install dhcpd and you don’t know where the configuration file located, you can use this command to search for the file. Despite you may not find the exactly dhcpd.conf file, you might find the similar file or we say as the sampe file. In RedHat 7.2 it’s reside on /usr/share/doc/dhcp-2.0pl5/dhcpd.conf.sample. you can copy this file to /etc/ and rename it as dhcpd.conf.

 

$ cp /usr/share/doc/dhcp-2.0pl5/dhcpd.conf.sample /etc/dhcpd.conf 

Then you’ll have /etc/dhcpd.conf. you should first change a little configuration in the file so that you can run dhcpd daemon suits your private network.you can start the dhcpd daemon by running dhcpd command, or from the /etc/rc.d/init.d/dhcpd as the startup script.

$ dhcpd &$ /etc/rc.d/init.d/dhcpd start 

 

the /etc/dhcpd.conf will look like this :

server-identifier dhcpd.ant.co.id;default-lease-time 43200;max-lease-time 86400; subnet 192.168.1.0 netmask 255.255.255.0 {        range 192.168.1.100 192.168.1.200;        option broadcast-address 192.168.1.255;        option routers 192.168.1.1;        option domain-name  “ant.co.id”;          option domain-name-servers 203.77.225.2, 203.77.255.2 ;        option netbios-name-servers 192.168.1.2, 192.168.1.4;        option netbios-node-type 8;         host printserver1 {                hardware ethernet 00:80:c8:bd:ab:99;                fixed-address 192.168.1.5;        }        host Limns {                hardware ethernet 00:90:cc:10:70:c1;                fixed-address 192.168.1.10;        }}subnet 202.144.157.208 netmask 255.255.255.240 {        range 202.144.157.215 202.144.157.221;        option broadcast-address 202.144.157.223;        option routers 202.144.157.222;        option domain-name-servers 202.144.157.210, 202.144.157.209;        option domain-name “ant.co.id”;        option time-offset 39600;        option ip-forwarding on;}

 

look at the above /etc/dhcpd.conf file, it has two network addresses, 192.168.1.0/24 and the 202.144.157.208/28, both network addresses will be served by one dhcp server. This server will have 2 network cards configured to use the IP Addresses, each will serve one network address.

The first 3 line is the global parameters can be used by the dhcp server, each subnet will be configured to use these parameters.

server-identifier dhcpd.ant.co.id;default-lease-time 43200;max-lease-time 86400; 

 

server-identifier  specify the server name, the server that run dhcpd daemon, and the default-lease-time will specify the lease time will expire when using dhcp. And the max-lease-time is the maximum time IP Address retain in the client computer. When the lease time expire, the client workstation will search the dhcp server to renew its IP Address.

subnet 192.168.1.0 netmask 255.255.255.0 {        range 192.168.1.100 192.168.1.200;        option broadcast-address 192.168.1.255;        option routers 192.168.1.1;        option domain-name  “ant.co.id”;          option domain-name-servers 203.77.225.2, 203.77.255.2 ;        option netbios-name-servers 192.168.1.2, 192.168.1.4;        option netbios-node-type 8;}

 

the subnet parameter followed by  the network address and subnet mask that will be served to have dynamic ip address. And within this subnet specific parameter there will be another options :

 

No parameters Description

1

range 192.168.1.100 192.168.1.200

Specify the range of IP Address that you want to include in the DHCP scope

2

option broadcast-address 192.168.100.255

Specify the broadcast address of your network

3

option routers 192.168.100.1

Specify the gateway address

4

option domain-name “ant.co.id”;

Specify the domain name here.

4

option domain-name-servers ns1.ant.co.id, ns2.ant.co.id;

Specify the DNS server address, you can use “,” to have multiple DNS server Addresses

5

option ip-forwarding on

Set the IP forwarding on

6

option netbios-name-servers

Wins server is specify here, same with the DNS server, you can use the “,” to have multiple wins server.

7

option netbios-node-type

Netbios type is specified here

 

You can also have a computer or hosts to have a fixed IP Address, the fixed IP Address given to a number of computers should be out of the range that we specify in the specific subnet parameters, we do this to avoid the same computer have a conflicting IP Address.

  

      host printserver1 {                hardware ethernet 00:80:c8:bd:ab:99;                fixed-address 192.168.1.5;        } 

these 4 lines tell the dhcp daemon to give a specified IP Address to a computer with the MAC address of 00:80:c8:bd:ab:99 (as we learn before that MAC address is uniquely given by the manufacturer of the NIC). This host is named printserver1, and it is given the IP Address of 192.168.1.5, no other computer will have this IP Address. You can add as many host as you want to give a fixed IP Address by specifying the similar parameters.

You can see the lists of IP Address being leased by the dhcp server in the /var/lib/dhcpd.lease file. All record pertaining to the IP Address given to a computer are available here. You can see the computer name, the ip Address, the lease time, and the expire time, as well as the MAC address.

$ more /var/lib/dhcpd/dhcpd.lease   lease 192.168.100.150 {        starts 2 2003/09/16 14:46:34;        ends 6 2003/10/11 14:46:34;        hardware ethernet 00:48:54:3b:79:8d;        uid 01:00:48:54:3b:79:8d;        client-hostname “sekre001”;}lease 192.168.100.150 {        starts 2 2003/09/16 14:50:31;        ends 2 2003/09/16 20:50:31;        hardware ethernet 00:f8:74:ab:79:8d;        uid 02: 00:f8:74:ab:79:8d;        client-hostname “sekre004”;}lease 192.168.100.150 {        starts 2 2003/09/16 14:50:31;        ends 2 2003/09/16 14:50:34;        hardware ethernet 00:78:09:b3:61:df;        uid 00:78:09:b3:61:df;        client-hostname “sekre003”;}

  

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s