Linux-Noob Forums

Full Version: how to setup a dhcp server
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

first things first, make sure you have your dhcp software installed

 

to check it quickly do this

 



Code:
rpm -qa dhcp*
dhcp-devel-3.0.1rc12-4
dhcp-3.0.1rc12-4




 

If it doesnt display anything you can download the RPMs and install them manually, or click on the redhat/system settings/add remove applications/Servers/Network Servers and put a check mark beside DHCP server.

 

ok once it is installed now you have to configure it, this is done by manually editing a file called /etc/dhcpd.conf

 

if the file does not yet exist don't worry, there is a sample stored on your distro,

 

to find it do this

 



Code:
updatedb && locate dhcpd.conf




 

it will probably be somewhere like this

 

/usr/share/doc/dhcp-3.0.1rc12/dhcpd.conf.sample

 

Copy this file to /etc as follows

 



Code:
cp /usr/share/doc/dhcp-3.0.1rc12/dhcpd.conf.sample
/etc/dhcpd.conf




 

Now edit the file and change the ip subnet/netmask settings to your liking and save the file.

 

To start the dhcp server you'll need a leases file created otherwise it will fail to start (first time start). Do as follows to create the file

 



Code:
touch /var/lib/dhcp/dhcpd.leases




 

Now we want it to start at boottime, so lets tell chkconfig to start it at boot by doing

 



Code:
chkconfig --level 35 dhcpd on




 

That's it, now we want to start the server, to do so try this

 



Code:
/etc/init.d/dhcpd start




 

ok, connect a client to the server with dhcp enabled and see do they get an ip !

 

If you want to share the internet via this DHCP server then try the following

 



Code:
iptables -t nat -F POSTROUTING

iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -j MASQUERADE




 

The first line CLEARS your current IPTABLEs rules so don't do it unless you really intend to do it. The second line shares out 10.0.0.1-10.0.0.255 as long as the client points their gateway to 10.0.0.1.

 

here is a sample dhcpd.conf file

 

 



Code:
ddns-update-style interim;
ignore client-updates;
filename "pxelinux.0";

subnet 10.0.0.0 netmask 255.255.255.0
{

   # --- default gateway
   option routers   10.0.0.1;
   option subnet-mask  255.255.255.0;

   option nis-domain  "domain.org";
   option domain-name  "domain.org";
   option domain-name-servers  10.0.0.1;

   option time-offset  -18000; # Eastern Standard Time
   #   option ntp-servers  10.0.1.1;
   #   option netbios-name-servers 10.0.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 10.0.0.128 10.0.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;
   }
}




 

 

cheers

 

anyweb

Do you need to install this in order to run a webhosting service?

use:

Quote:service dhcpd start
instead of:
Quote:/etc/init.d/dhcpd start
 

does the same, but using 'service' is nicer :P


i want to setup dhcpv6 server on linux box(RHEL6), which can provide ipv6 addresses when connect to a router.

Can somebody let me know how can a setup this?


Hi masterblaster,

 

You need to install the dhcp package:

 



Code:
# yum install dhcp




 

You now need to edit /etc/dhcp/dhcp6.conf and set up your DHCPv6 scope for the subnet you want to offer IPv6 addresses to (take a look at /usr/share/doc/dhcp*/dhcpd6.conf.sample).

 

Finally, once you have finished editing the config file for the DHCPv6 server, launch it:

 



Code:
# service dhcpd6 start




 

and perhaps also set it to run at start up:

 



Code:
# chkconfig dhcpd6 on





Just to thread-hijack.... do you know anything about dynamic DNS? I can set up DNS and DHCP individually, but there's something new in DHCPd that seems to prod a host+IP dynamically into the DNS zone (without it inserting a new entry into the DNS file and reloading the configuration), the idea being that you just let DHCP allocate an address and DNS picks it up - handy for static leases or address reservations.

 

I've seen settings displayed in Webmin, but the webmin guides are very scant on details, and I haven't found a HowTo that properly explains how it all works. I've tried setting up a few from Webmin then looking at the zone files it creates, but I'm still none the wiser. I'd like to properly get this working if possible.


In short, no. :(

 

I've played with this The Microsoft Way, with Active Directory, MS's DNS Server and MS's DHCP Server, where it is all automatic, but not with BIND and dhcpd. To be honest, I haven't yet had a huge need to, and as you've discovered, it doesn't seem that anyone has sat down and produced a decent guide. Have you seen this guide? Again, I'm afraid I haven't looked into this in detail, so I don't know how good that is.


Quote:Have you seen this guide? Again, I'm afraid I haven't looked into this in detail, so I don't know how good that is.
mmm.. actually, that guide isn't too bad. Other guides I've seen have been outdated (and talk about perl scripts to modify zone files) but that one could be the ticket, ta. Most of it seems like the standard DNS/DHCP stuff I know, but it's the additional directives that are useful.

 

Ta, lad - that could save me bacon!