- I can smell the end of the week!
- Is baht your bath day??!?
    - from a valeri dachev's blog ( http://valery.bgit.net/blog-bg/?p=281 ) - it's in Bulgarian.

    
    
Keywords: isc-dhcp3-server , dhcpd , dhcp-server , quick dhcpd howto , FreeBSD dhcpd , FreeBSD dhcpd


Why am I writing this quick 'n dirty howto?

Well, I've been asked from some people how do they handle dhcpd (not only under freebsd) and so... here it is!


Where to start from?

If you are using *BSD especially fbsd go to: /usr/ports/net/isc-dhcp3-server/
(there is a free implementation for ipv6 but I've never used ipv6? any help and comments are welcome!)

there you do: 
#>make install distclean

If you've compiled dhcpd before you surely have '/var/db/ports/isc-dhcp3-server/options' file where
the options for this port is saved!
You can open it to change them, or simply make rm /var/db/ports/isc-dhcp3-server/options and you'll have options screen again!
Nice trick huh? :)

Okay, we are presented with some options:

    - WITHOUT_DHCP_PARANOIA - don't turn on this option, I've never got dhcpd working ok with this, 
        maybe I did something wrong(any comments?) but I never got my boxes finding this machine...
    - WITHOUT_DHCP_JAIL - I didn't tested this...
    - WITHOUT_DHCP_SOCKETS - better use bpf0 device, I think the problem with PARANOIA setting came from here..
    - WITHOUT_DHCP_LDAP - I've never used LDAP server, any additional info appreciated!
    - WITHOUT_DHCP_LDAP_SSL - read above
    - WITH_OPENSSL_BASE - read above
    - WITHOUT_OPENSSL_PORT - read above
    - WITHOUT_DHCP_LQ - wtf?(help needed, no time to google :)
    

    
So, you have isc-dhcp3-server installed and you got your /usr/ports/distfiles cleaned up!

The next step - go to /usr/local/etc/
do
#>cp dhcpd.conf.sample dhcpd.conf

And open dhcpd.conf with your favourite text editor(mine is vim!);

Actually you can safely open a entirely new file is you are going to copy/paste from here...

Okay, lets begin configuration....

on the first line, where no class, network or host is defined we enter our default values:
-------------------
# option definitions common to all supported networks...

# this is the 'search domain' that is sent to the box
option domain-name "example.com";

# this is a list of dnses
# WARNING: The dnses MUST be resolvable, because DHCPD resolves the IPS and sends THEM to the client!
option domain-name-servers ns.example.com, ns1.example.com;

# That's the default 'lease-time' - means how often the host will ask dhcp server for reconfiguration
default-lease-time 600;

# that's max lease-time...
max-lease-time 7200;

# use this if this is your network default dhcp server
authoritative;

# set to none to disable dns update
ddns-update-style ad-hoc;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
-------------------
(I've used default comments)
In my case, I have no different network name and dnses so I put them above all...


You can also put here stuff like:
        option routers 10.1.1.1;
        option broadcast-address 10.1.1.255;
        option subnet-mask 255.255.255.0;
etc.etc.... but not recommended, better define them in the network definition.

Now, lets go with networks configuration, you see something like:
------------------
subnet 10.1.1.0 netmask 255.255.255.0 {
        #the interface that this network belongs to
        interface "rl0";
        #this is a FREE LEASE address space!!!!
        #WARNING: If you don't want an unknown boxes to get IPS DO NOT DEFINE THIS!
        # If you want a MAC->IP assignment define ONLY HOSTS and NO RANGE!!!
        range 10.1.1.10 10.1.1.20;
        # Seems familiar? Yep this is the default gw of the dhcped box
        option routers 10.1.1.1;
        # And this is the broadcast of course!
        option broadcast-address 10.1.1.255;
        # I won't write for this..
        option subnet-mask 255.255.255.0;
        #Uh oh! This is the bootp Machines range! If you wanna know what bootp is: http://www.k12ltsp.org/server.html give it a read...
        # If you won't need this(most cases) Leave it commented!
        #range dynamic-bootp 192.168.254.1 192.168.254.7;
        # for more options go to dhcpd home: http://www.isc.org/sw/dhcp/ or the man 5 dhcpd.conf
}
------------------

So... we have our network defined, now lets define the hosts:

------------------
host thebox {
        #these are the MAC-s of the machine
        hardware ethernet 00:13:10:0a:aa:2c;
        hardware ethernet 00:13:10:0A:AA:2C;

        # and this is the assigned ip!
        fixed-address 10.1.1.10;

        #If you'll bootp the machine, this is the file that's going to be sent
        #  filename "vmunix.passacaglia";
        #this is the server address for the bootp file, here you can have 'next-server' option, but it's not a scope of this howto, 
        #read man 5 dhcpd.conf
        #  server-name "toccata.fugue.com";
}
------------------


That's it with the config! It's pretty simple, there are alot of other features like classes,pools,groups but RTFM if you need them.

Okay, lets config the fbsd load the dhcpd server at start up... for this you need to edit /etc/rc.conf. Open it with text editor...

you must have:
------------------
dhcpd_enable="YES"
dhcpd_ifaces="rl0 fxp0" #...etc
------------------


WARNING: To have dhcpd started at all you AT LEAST need a 
subnet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx { } - empty declaration

for EVERY net you have on the listed in the rc.conf interfaces!

after all this, you simply execute
/usr/local/etc/rc.d/isc-dhcpd.sh start


That's it! You have it running right?

WARNING: This quick 'n dirty how to doesn't cover ch-rooting, jailing' etc for dhcpd but If you have experience whit this send me email at 
valqk {ат} lozenetz {дот} org.

Have a nice day!