DHCP Server Configuration
Introduction:-
Dynamic Host Configuration Protocol (DHCP) automatically
assigns IP addresses and other network configuration information (subnetmask,
broadcast address, etc) to computers on a network. A client configured for DHCP
will send out a broadcast request to the DHCP server requesting an address. The
DHCP server will then issue a "lease" and assign it to that client.
The time period of a valid lease can be specified on the server.
- DHCP assignment:
- Lease Request: Client broadcasts request to DHCP server with a source address of 0.0.0.0 and a destination address of 255.255.255.255. The request includes the MAC address which is used to direct the reply.
- IP lease offer: DHCP server replies with an IP address, subnet mask, network gateway, name of the domain, name servers, duration of the lease and the IP address of the DHCP server.
- Lease Selection: Client recieves offer and broadcasts to DHCP servers that will accept given offer so that other DHCP server need not make an offer.
- The DHCP server then sends an ack to the client. The client is configured to use TCP/IP.
- Lease Renewal: When half of the lease time has expired, the client will issue a new request to the DHCP server.
Requirement:-
·
Package = dhcp (dhcp-3.0.5-21.el5,
dhcp-devel-3.0.5-21.el5, dhcpv6-client-1.0.10-17.el5, dhclient-3.0.5-21.el5)
·
Service = dhcpd
- Port No. = 67
- Configuration File = /etc/dhcpd.conf
Per quest:-
- Configure IP = 192.168.100.250
- Configure Hostname = dhcp
- Firewall must be disabled.
Step-1: To check dhcp rpm
package is installed or not by following this command:
(if installed then it will show dhcp packages)
[root@dhcp ~]# rpm -qa | grep –i dhcp* or
[root@dhcp ~]# rpm –qa dhcp*
dhcp-3.0.5-21.el5
dhcp-devel-3.0.5-21.el5
libdhcp-devel-1.20-10.el5
dhcpv6-client-1.0.10-17.el5
libdhcp-1.20-10.el5
libdhcp4client-3.0.5-21.el5
libdhcp6client-devel-1.0.10-17.el5
libdhcp4client-devel-3.0.5-21.el5
dhclient-3.0.5-21.el5
If not installed,
then installed the packages using Yum command:
[root@dhcp ~]# Yum
Install dhcp* lib*
Step-2: Check and Configure the Network Card:
[root@dhcp ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
(Original
File):
#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
(Modified
File):
#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:26:56:fc
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.100.250
TYPE=Ethernet
Step-3: After complete
the NIC configure you have to change the host name by following this command:
[root@dhcp ~]# vi /etc/sysconfig/network
(Original File):
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
(Modified File):
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=dhcp
Step-4: Copy & Rename the
DHCP configuration file & Change the permission by following this
command:
[root@dhcp ~]# cd /usr/share/doc/dhcp-3.0.5/
[root@dhcp dhcp-3.0.5]# cp
dhcpd.conf.sample /etc/dhcpd.conf
Step-5: Edit the dhcpd.conf file
as follows:
[root@dhcp
~]# vi /etc/dhcpd.conf
(Original File):
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option
routers
192.168.0.1;
option
subnet-mask
255.255.255.0;
option
nis-domain "domain.org";
option
domain-name
"domain.org";
option
domain-name-servers 192.168.1.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.0.128 192.168.0.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;
}
}
(Modified File):
ddns-update-style
interim;
ignore
client-updates;
subnet
192.168.100.0 netmask 255.255.255.0 {
# --- default
gateway
option routers 192.168.100.254;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "gsnone.com";
option domain-name-servers ns1.gsnone.com;
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;
allow booting;
allow bootp;
# option-128 code 128 = string;
# option-129 code 129 = text;
next-server 192.168.100.250;
filename "pxelinux.0";
range dynamic-bootp 192.168.100.151
192.168.100.199;
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;
}
}
Details Explanation
01
|
ddns-update-style interim; # Required for dhcp
3.0+ / Red Hat 8.0+
|
|
02
|
ignore client-updates;
|
03
|
|
|
04
|
subnet 192.168.1.0 netmask 255.255.255.0 {
|
05
|
|
|
06
|
range 192.168.1.128 192.168.1.254; # Range of IP addresses
to be issued to DHCP clients
|
07
|
option
subnet-mask
255.255.255.0; # Default subnet mask to be used by DHCP
clients
|
08
|
option
broadcast-address
192.168.1.255; # Default broadcastaddress to be used by
DHCP clients
|
09
|
option
routers
192.168.1.1; # Default gateway to be used by DHCP
clients
|
|
10
|
option
domain-name
"your-domain.org";
|
11
|
option
domain-name-servers 40.175.42.254,
40.175.42.253; # Default DNS to be
used by DHCP clients
|
12
|
option
netbios-name-servers 192.168.1.100;
# Specify a WINS server
for MS/Windows clients.
|
13
|
#
(Optional. Specify if used on your network)
|
|
14
|
|
15
|
#
DHCP requests are not forwarded. Applies when there is more than one ethernet
device and forwarding is configured.
|
|
16
|
# option ipforwarding off;
|
17
|
|
|
18
|
default-lease-time 21600; # Amount of time in seconds
that a client may keep the IP address
|
19
|
max-lease-time 43200;
|
|
20
|
|
21
|
option
time-offset
-18000;
# Eastern Standard Time
|
22
|
# option
ntp-servers
192.168.1.1; # Default NTP server to
be used by DHCP clients
|
23
|
# option
netbios-name-servers 192.168.1.1;
|
|
24
|
# --- Selects point-to-point node (default is hybrid). Don't change this
unless you understand Netbios very well
|
25
|
# option netbios-node-type 2;
|
|
26
|
|
27
|
#
We want the nameserver "ns2" to appear at a fixed address.
|
|
28
|
#
Name server with this specified MAC address will recieve this IP.
|
29
|
|
|
30
|
host ns2 {
|
31
|
next-server
ns2.your-domain.com;
|
|
32
|
hardware
ethernet 00:02:c3:d0:e5:83;
|
33
|
fixed-address
40.175.42.254;
|
|
34
|
}
|
35
|
|
|
36
|
#
Laser printer obtains IP address via DHCP. This assures that the
|
37
|
#
printer with this MAC address will get this IP address every time.
|
|
38
|
|
39
|
host laser-printer-lex1 {
|
|
40
|
hardware
ethernet 08:00:2b:4c:a3:82;
|
41
|
fixed-address
192.168.1.120;
|
|
42
|
}
|
43
|
}
|
Step-6: Create a dhcp.leases file
that the DHCP server grants to the DHCP client to use a particular IP
address. If it does not exist dhcp server will fail to provide IP address for
dhcp cient.
[root@dhcp ~]# touch
/var/lib/dhcpd/dhcpd.leases
[root@dhcp ~]# service
network restart
[root@dhcp ~]# service
dhcpd restart
Step-7: Client Configuration for
using DHCP.
Linux Client
[root@dhcp ~]# vi
/etc/sysconfig/network-scripts/ifcfg-eth0
#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
TYPE=Ethernet
Windows Client
From NIC Properties =>> set Obtain an IP Address Automatically
Step-7: Renewing IP Address
Renew an IP Address in Linux
The -r flag
explicitly releases the current lease, and once the lease has been released,
the client exits. For example, open terminal and type the command:
[root@dhcp ~]# dhclient –r
Now obtain fresh IP:
[root@client1 ~]# dhclient
Or you can put the two commands on a single line:
[rnbsp; oot@client1 ~]# dhclient -r; dhclient
There is no need to restart network service. Above
command should work with any Linux distro such as RHEL, Fedora, and others. On
a related note you can also try out the following commands:
[root@client1 ~]# ifdown eth0
[root@client1 ~]# ifup eth0
[root@client1 ~]# /etc/init.d/network restart
[root@client1 ~]# ifup eth0
[root@client1 ~]# /etc/init.d/network restart
Renew an IP Address in
Windows
Open Command Prompt → Then Type The following command
C:\Documents
and Settings\Administrator> Ipconfig
/release
C:\Documents
and Settings\Administrator> Ipconfig /renew
C:\Documents
and Settings\Administrator> Ipconfig
/all
No comments:
Post a Comment