Thursday, 26 June 2014

On CentOS 6 or Red Hat 6, installing a DHCP server

On CentOS 6 or Red Hat 6, installing a DHCP server is not too difficult. I’ll show you how it works!



First, install the DHCP server:
$ sudo yum install dhcp


The configuration file (blank) is located here:

/etc/dhcp/dhcpd.conf


To copy a sample configuration file over for the production file, use the following command:


$ sudo cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf


Next edit /etc/dhcp/dhcpd.conf as needed, then save:

$ sudo nano /etc/dhcp/dhcpd.conf


For help on the syntax see the Red Hat doc here.



After making changes to the /etc/dhcp/dhcpd.conf file as needed, one other file must be changed to specify the NIC that dhcp listens on.

$ sudo nano /etc/sysconfig/dhcpd


# Command line options here
DHCPDARGS=eth0
Finally, cross your fingers, and start DHCP:
$ sudo service dhcpd start
If upon starting the dhcp server it fails, check /var/log/messages to look for what is wrong.

$ sudo service dhcpd start
Starting dhcpd:                                            [FAILED]


$ cat /var/log/messages

Dec 10 08:15:35 centos dhcpd: No subnet declaration for eth0 (10.112.12.34).

Dec 10 08:21:36 centos dhcpd: bad range, address 10.112.239.20 not in subnet 10.112.12.0 netmask 255.255.255.224


On CentOS 6 or Red Hat 6, installing a DHCP server is not too difficult. I’ll show you how it works!



First, install the DHCP server:
$ sudo yum install dhcp


The configuration file (blank) is located here:

/etc/dhcp/dhcpd.conf


To copy a sample configuration file over for the production file, use the following command:


$ sudo cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf


Next edit /etc/dhcp/dhcpd.conf as needed, then save:

$ sudo nano /etc/dhcp/dhcpd.conf


For help on the syntax see the Red Hat doc here.



After making changes to the /etc/dhcp/dhcpd.conf file as needed, one other file must be changed to specify the NIC that dhcp listens on.

$ sudo nano /etc/sysconfig/dhcpd


# Command line options here
DHCPDARGS=eth0
Finally, cross your fingers, and start DHCP:
$ sudo service dhcpd start
If upon starting the dhcp server it fails, check /var/log/messages to look for what is wrong.

$ sudo service dhcpd start
Starting dhcpd:                                            [FAILED]


$ cat /var/log/messages

Dec 10 08:15:35 centos dhcpd: No subnet declaration for eth0 (10.112.12.34).

Dec 10 08:21:36 centos dhcpd: bad range, address 10.112.239.20 not in subnet 10.112.12.0 netmask 255.255.255.224


No comments:

Post a Comment