Jump to content


We use cookies to log you in, for ads and for analytics. OK

Photo

how to setup a dhcp server


7 replies to this topic

#1 anyweb

anyweb

    Administrator

  • Admin
  • PipPipPipPipPipPipPipPip
  • 3,692 posts

Posted 21 May 2004 - 04:59 PM

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

to check it quickly do this

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

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

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

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

chkconfig --level 35 dhcpd on

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

/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

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


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

Edited by Dungeon-Dave, 27 July 2009 - 07:18 AM.
Redid CODE tags for clarity

  • inetryconydot, BycleIlliny, and 23 others like this
i do windows too

#2 alan

alan

    Noob

  • Members
  • Pip
  • 13 posts

Posted 03 June 2004 - 09:26 PM

Do you need to install this in order to run a webhosting service?
  • Wilfredlui, Clementppo, Magdalenadle and 2 others like this

#3 TormentoR

TormentoR

    Noob

  • Members
  • Pip
  • 14 posts

Posted 09 June 2004 - 12:10 PM

use:

service dhcpd start

instead of:

/etc/init.d/dhcpd start


does the same, but using 'service' is nicer :P
  • Wilfredlui and Ruperttln like this

#4 masterblaster

masterblaster

    Noob

  • Members
  • Pip
  • 1 posts

Posted 25 August 2011 - 11:28 AM

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?
  • Ruperttln likes this

#5 hybrid

hybrid

    Linux-Noob Frequent Member

  • Admin
  • PipPipPipPipPipPipPipPip
  • 1,009 posts

Posted 28 August 2011 - 06:49 AM

Hi masterblaster,

You need to install the dhcp package:

# 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:

# service dhcpd6 start

and perhaps also set it to run at start up:

# chkconfig dhcpd6 on

  • Ruperttln likes this
My website | Portfolio

FOSSwire -- all about free and open source software, featuring tips, tricks, tutorials, reviews, articles and all the latest news from the free software universe.

#6 Dungeon-Dave

Dungeon-Dave

    Linux-Noob Frequent Member

  • Moderator
  • PipPipPipPipPipPipPip
  • 972 posts

Posted 29 August 2011 - 03:52 PM

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.
  • Ruperttln likes this

#7 hybrid

hybrid

    Linux-Noob Frequent Member

  • Admin
  • PipPipPipPipPipPipPipPip
  • 1,009 posts

Posted 30 August 2011 - 05:56 PM

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.
  • Ruperttln likes this
My website | Portfolio

FOSSwire -- all about free and open source software, featuring tips, tricks, tutorials, reviews, articles and all the latest news from the free software universe.

#8 Dungeon-Dave

Dungeon-Dave

    Linux-Noob Frequent Member

  • Moderator
  • PipPipPipPipPipPipPip
  • 972 posts

Posted 31 August 2011 - 03:47 PM

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!
  • Ruperttln likes this



Reply to this topic



  

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users