Configuring DHCP on CentOS

thingsplaneServers

Dec 9, 2013 (3 years and 10 months ago)

189 views







2010/2011


IICT


Frankie Inguanez


[
CONFIGURING DHCP ON
CENTOS
]

This guide will inform the user on how to
configure DHCP

i
n the
CentOS 5.5

Linux Distribution OS.

Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
2


Contents

Conf
iguring DHCP on CentOS

................................
................................
................................
........................

3

Configuring Ubuntu to obtain IP via DHCP (GUI)

................................
................................
..........................

7

Configuring Ubuntu to obtain IP via DHCP (CLI)

................................
................................
...........................

9




Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
3


C
onfiguring DHCP on CentOS


1.

Open a terminal window:



2.

S
witch user to administrator
.

su


3.

Edit the DHCP configuration file

v
im

/etc/dhcpd.conf


or


nano /etc/dhcpd.conf



Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
4



4.

Take note of the location of the sample configuration file.



N.B.
You are to replace the * with the actual dhcp version number.
You can find the version
number by pressing tab twice
.


5.

Copy the sample configuration file to the actual file

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

N.B.

The current version n
umber may different from the illustrated one. Check your current
version.


N.B.

When asked to co
nfirm whether you want to overwrite the configuration file type y then
press enter.




Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
5


6.

E
dit the configuration file.

v
im /etc/dhcpd.conf


o
r


nano /et
c/dhcpd.conf


7.

Use the sample configuration as a guide for your configuration. Either add a #

at the beginning
of each line

to comment the current settings or

else press

delete

to remove
. This guid
e will
apply the following settings:


Network Address:

192.168.1.0

Subnet Mask
:

255.255.255.0

Default Lease Time:

600

Maximum Lease Time:

1700

Range:

192.168.1.100


192.
168⸱.200






8.

Save and close the configuration file.


9.

Create the dhcpd.leases file
.

touch /var/lib/dhcpd/dhcpd.
leases


10.

Give read and write permissions for all

users on the dhcpd.leases file
.

chmod

+rw /var/lib/dhcpd/dhcpd.leases


11.

Edit the system configuration file for dhcpd

vim /etc/sysconfig/dhcpd


or


nano

/etc/sysconfig/dhcpd



Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
6



12.

S
et the name of the network interface to use for dhcp configuration

(
generally e
th0
)
.




13.

Save and close the configuration file.


14.

Start the dhcp server

/sbin/service dhcpd start




15.

To stop the dhcp server type:

/sbin/service dhcpd stop


16.

To restart the dhcp server type:

/sbin/ser
vice dhcpd restart


17.

To check the status of the dhcp server type:

/sbin/service dhcpd sta
tus


18.

To configure the dhcp server while operational use the omshell command.



Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
7


Configuring Ubuntu to obtain IP via DHCP

(
GUI
)


1.

Launch the network connections utility from the system preferences menu.



2.

Select the network interface then click edit.




Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
8



3.

Select the IPv4 se
ttings tab and select the automatic dhcp option.



4.

Click apply then enter the administrative
password
.



N.B.
If you have previous
edited the network interfaces file then you will need to re
-
amend it.

Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
9


Configuring Ubuntu to obtain IP via DHCP

(
C
LI
)


1.

Open

a terminal window
.


2.

Ei
ther switch user to administrator or perform commands using administrative privileges.

su


3.

Edit the interfaces file
.

nano /etc/
network/interfaces

(
If you s
witched user to root
)


or


sudo

nano

/etc
/network
/interfaces


N.B.

I
nst
ead of nano you can us
e vi.


4.

Set the network interface to accept an IP address via dhcp.



5.

Save and close the configuration file.



Configuring DHCP on CentOS


Supporting Network Operation System
-

Notes

Page
10



6.

Restart the networking interfaces

/etc/init.d/networking restart

(
If you switched user to root
)


o
r


sudo /etc/init.d/networking restart


7.

Confi
rm that the IP address has been properly obtained.

ifconfig