I am planning to install DHCP on my Linux Server. I do not know that much in Linux (Red Hat), however. How can I install and configure a DHCP server on my system?
First off, a definition. DHCP is the Dynamic Host Configuration Protocol and rather than use the default DHCP server included with your Red Hat / Fedora Linux system, I recommend that you pop over to the Internet Software Consortium and Download the latest version of the DHCP Server. As I write this, it’s at version 3.0.3.
Why is it important to have the latest version? In a word, security. As with any software that you’re going to run on your server, it’s critically important that you have the very latest version of this ‘daemon’ (as we Linux geeks call programs that run on the server without intervention) on your system. It’s also very important to shut off any services you aren’t using (a process I detail in my popular book Teach Yourself Unix System Administration in 24 Hours, by the way).
So once you’ve downloaded the latest version of the software, you’ll want to unpack it with:
Now, move to the new directory that contains all the source and type in the following commands (the tons of output these commands have has been deleted to save our sanity here):
$ make
Assuming all has gone well, switch to root by using the sudo command and install the new server:
you’ll be prompted for the root password, then, if you typed it in correctly, the new DHCP server will be installed onto your system.
Good. Now you have the latest DHCP server it’s time to configure it properly for your environment. This is best done by copying the file server/dhcp.conf from the installation directory into your /etc directory, like this:
This time, since you just did a sudo command a few seconds ago, you won’t be prompted for your password (an exceedingly slick feature of sudo, actually!)
Now, again using sudo, it’s time to edit the configuration file to match your system configuration. Here’s what the dhcp.conf file looks like:
subnet 192.168.1.0 netmask 255.255.255.0 {
# The range of IP addresses the server will issue to
# DHCP enabled PC clients booting up on the network
range 192.168.1.201 192.168.1.220;
# Set the amount of time in seconds that
# a client may keep the IP address
default-lease-time 86400;
max-lease-time 86400;
# Set the default gateway to be used by
# the PC clients
option routers 192.168.1.1;
# Don’t forward DHCP requests from this NIC interface
# to any other NIC interfaces
option ip-forwarding off;
# Set the broadcast address and subnet mask
# to be used by the DHCP clients
option broadcast-address 192.168.1.255;
option subnet-mask 255.255.255.0;
# Set the DNS server to be used by the
# DHCP clients
option domain-name-servers 192.168.1.100;
# Set the NTP server to be used by the
# DHCP clients
option nntp-server 192.168.1.100;
# If you specify a WINS server for your Windows clients,
# you need to include the following option in the dhcpd.conf file:
option netbios-name-servers 192.168.1.100;
}
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}
# You can also assign specific IP addresses based on the clients’
# ethernet MAC address as follows (Host’s name is “smallfry”:
host smallfry {
hardware ethernet 08:00:2b:4c:59:23;
fixed-address 192.168.1.222;
}
As with many Linux configuration files, this is actually fairly well documented, especially since you should be able to type man dhcp-options to get an exhaustive explanation of each and every configuration option.
In particular, make sure you set the domain name properly, identify your set of DNS servers by name, and define the subnet range for which you want to provide services via DHCP.
Once that’s all configured to your liking, a little bit more tweaking is required to get everything checked and started properly:
Will make sure that you have a ‘leases’ file, a critical part of how the DHCP server tracks what systems it’s seen and serviced.
This will check your configuration and make sure it will be added to the list of daemons to start up at boot time from now on. Very useful if you don’t want to remember to restart it each time!
Now you should be running a DHCP server on your system. Check to make sure it’s running by using ps aux | grep dhcp but you should be — hopefully — good to go!
how to install dhcp in fedora 13.
error in this step :
sudo touch /var/lib/dhcp/dhcp.leases
i got error please help how to solve this problem
touch: cannot touch `/var/lib/dhcp/dhcp.leases’: No such file or directory
pls give me solution for this problem
thank u……….
by KS
A working configuration example
Server ip : 172.27.0.10
Swtich ip / gateway ip of server : 172.27.0.100
Option domain –name servers : 172.27.0.6
Please note default vlan 172.27.0.x in this case
Switch and server need to be in default lan for communication / or else we need to trunk in case other vlan connected , we need to configure vconfig on server to communicate
For biggner I would recommend to go for the default vlan connectivity
Example :
ddns-update-style interim;
ignore client-updates;
default-lease-time 43200;
max-lease-time 43200;
authoritative;
#—–subnet mask– broadcast– gateway-#
option subnet-mask 255.255.255.0;
#option broadcast-address 192.168.1.1;
option routers 172.27.0.100;
option domain-name-servers 172.27.0.6;
# ———– Server Scope and vlan1 with switches and server————–#
subnet 172.27.0.0 netmask 255.255.255.0 {
#range 172.27.0.0 172.27.0.50;
option routers 172.27.0.1;
#option subnet-mask 255.255.255.0;
option broadcast-address 172.27.0.255;
#option domain-name-servers 172.27.0.5;
}
# ———– clients1 Scope-vlan2————-#
subnet 172.27.1.0 netmask 255.255.255.0 {
range 172.27.1.3 172.27.1.200;
option routers 172.27.1.1;
option subnet-mask 255.255.255.0;
option broadcast-address 172.27.1.255;
#option domain-name-servers 192.168.1.1 #
}
Save the file
Chkconfig –list dhcpd on
{ For enabling the service on all run levels }
Service dhcpd start
In case , dhcp server faild to start , check with log messages
/var/log/messages
Check for the ip helper address in layer 3 swtich , which act as dhcp-relay
Which has to be configured as 172.27.0.10
Troubleshooting Dhcp server start up error :
1) Run the Dhcp service in debug mode
2) Check the ip configuration
3) Check for syntax errors in dhcpd.conf file
4) Check for the right location of the dhcpd file
5) Ping test between the switch and server
6) Possible conflict of other dhcp server may be the issue
dhcpd in the foreground in debug mode with /usr/sbin/dhcpd -d –f
Hopefully, a DHCP server like the one we’ll be configuring will respond. Running tcpdump shows a dhcp request looks like:
17:26:02.003956 00:00:00:00:00:00 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0×0800), length 342: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request, length 300
You should notice DHCP running in the process (ps) list. Any problems, check syslog
Congratulations you have finally configured In easy steps
i check this tips but its all not working on my linu red hat fedora core 7
if anybody can help me for this that how i can install yum on linux red hat fedora core 7
thanx
I am unable to get dhcp to start on Fedora 8, I have the config file for dhcp, but it does not show up on the enable list for the firewall, would that be the reason that it will not start through the terminal?
how can i install fedora 9 server on sunfire x4200,x2200 amd server
with firewall,squid proxy,email server
Please post me
This is pretty helpful. I’ve configured my DHCP, but I have a (maybe stupid) question…
I’m using a Linksys WRT54G router as my switch. What physical connection do I have to make between the DHCP and the switch in order to get my server functioning? Do I just attach it to the stanard ports?
noname, tar archives unpack in the current directory, either spewing their files everywhere in the current directory or, ideally, creating a subdirectory of their own with all the files therein. In this case, look for a new subdirectory called “dhcp-303” or similar.
supposed help to others when it is INCOMPLETE is really frustrating. How the hell does one find where the output to the tar command went? Without knowing this, installing dhcp server is IMPOSSIBLE.
from a frusterated biginner.
Dear Dev,
How to configure vsftpd in fedora 5
Regards,
Roshan costa
Hi Dev,
How can i configure a DHCPD IN FEDORA 5 AND THE FTP SERVICE..
Regards,
Roshan Costa
The error output is from make – it means that a compiler – ‘cc’ – isn’t in your path. So installing gcc will fix this.
You can check compilation/setup options by entering
./configure –help
before actually configuring the package. If you for example want to install it somewhere other than /usr/local you need to set it in the configure line like so
./configure –prefix=/folder/to/install/into
If running some other unix rather than linux be sure to install and use gnu ‘make’ rather than the system supplied one (the same goes for ‘tar’)
a litle tutorial to how to configure DHCP
dhcp
it worked after i installed the gcc compiler.
I saw the post above that gets an error after make but can’t find the resolution.
I do ./configure, then make and get the error, and get the same error after make install:
[root@server2 dhcp-3.0.3]# sudo make install
make[1]: Entering directory `/root/dhcp-3.0.3/work.linux-2.2′
Installing in common
make[2]: Entering directory `/root/dhcp-3.0.3/work.linux-2.2/common’
cc -g -I/root/dhcp-3.0.3 -I/root/dhcp-3.0.3/includes -DLINUX_MAJOR=2 -DLINUX_MINOR=6 -c -o raw.o raw.c
make[2]: cc: Command not found
make[2]: *** [raw.o] Error 127
make[2]: Leaving directory `/root/dhcp-3.0.3/work.linux-2.2/common’
make[1]: *** [install] Error 1
make[1]: Leaving directory `/root/dhcp-3.0.3/work.linux-2.2′
make: *** [install] Error 2
Where do i find the DHCp after its installed?
i have a Intel P4 Pc with 945/946 intel motherboard and SATA HDD. How I can install RHEL 4 or Fedora core 5. How I can creat VPN, DHCP, DNS server in RHEL4/Fedora core 5.
In version 3.0.6 you must issue the commands at the top of this page in this order. (3 seperate commands)
./configure
make
make install
Then continue like normal …
i have downloaded the .tar, unpacked it, ./configure-make, are the commands i have done so far. but i have this lines after the make command
cc -g -I/root/dhcp-3.0.6 -I/root/dhcp-3.0.6/includes -DLINUX_MAJOR=2 -DLINUX_MINOR=4 -c -o raw.o raw.c
make[2]: cc: Command not found
make[2]: *** [raw.o] Error 127
make[2]: Leaving directory `/root/dhcp-3.0.6/work.linux-2.2/common’
make[1]: *** [all] Error 1
make[1]: Leaving directory `/root/dhcp-3.0.6/work.linux-2.2′
make: *** [all] Error 2
hello Suport, now i have dhcp server but that is very old now i want migrate this in new one , please guide me how can i take the backup of old ane restor same in new also let me know what configuration is require for dhcp installation in linux box.
For different vlans how can i set up my dhcp server so that my client in diff.vlans get ip from dhcp server.
Any one help me
i am highly appreciated.
You don’t need a DHCP server per VLAN. You will need to configure the L3 switch or router to forward IP broadcasts – Cisco uses IP helper command. When the router forwards the DHCP request it will “tell” the DHCP server from which subnet the request came. Your DHCP will then (if it supports it) allocate an appropriate IP address (ie one from that subnet). Some DHCP servers will only allocate addresses from their own subnet (in which case it won’t work).
We’re getting a bit out of my depths, but as far as I understand, you’d need a different DHCP server on each LAN segment.
I want to know whether dhcp works across VLAN.
Or in each VLAN , we need to install individual DHCP Server.
unless you really need to flexibility and power of a true blue dhcp server, try udhcpd. just google for it. its small and fairly stable for what its built for.
kjteoh