Firstly, you need to check if DHCP server is installed or not:
$ rpm -qa | grep 'dhcp'
If you see in the output a line like this:
dhcp-3.0.6-12.fc8
then you have already installed the service. Otherwise, you need to run the following command to install the service (first you need to switch your user account to the root user):
$ su -
Password:
# yum install dhcp
Now it is time to edit the configuration file for DHCP service. The configuration file is /etc/dhcpd.conf. It is empty in the beginning, but you can copy a sample file at /usr/share/doc/dhcp-3.0.6/dhcp.conf.sample to /etc directory as the starting point (you may have a different version number):
# cp /usr/share/doc/dhcp-3.0.6/dhcpd.conf.sample /etc/dhcpd.conf
The sample configuration file with some explanations are listed here:
- 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.0.1;
- option time-offset -18000; # Eastern Standard Time
- # option ntp-servers 192.168.0.1;
- # option netbios-name-servers 192.168.0.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;
- }
- }
Most options are self-explaining. For example:
You can also type the following command to get detailed explanations about these options:
$ man dhcpd.conf
Before we run DHCP service, we need to make sure the lease database file is created:
# touch /var/lib/dhcpd/dhcpd.leases
We can use chkconfig to run DHCP service on boot:
# chkconfig dhcpd on
Then, we can use service command to start DHCP server:
# service dhcpd start
Starting dhcpd: [ OK ]
If you have more than one NIC, usually you want to limit DHCP service for only one NIC (the one that connects the private network). Suppose that NIC is eth1, then you can add the following line to file /etc/sysconfig/dhcpd:
DHCPDARGS=eth1