pavement

DHCP

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
m
m (copied over from one of the XDM pages)
Line 14: Line 14:
  
 
==DHCP - Install and setup==
 
==DHCP - Install and setup==
Server setup.
 
  
install through package
+
===Installation===
 +
install through package:
 
  # pkg_add -r isc-dhcp3-server
 
  # pkg_add -r isc-dhcp3-server
  
We do this so we can define the root path for the diskless system.
+
or ports:
 +
# cd /usr/ports/nets/isc-dhcp3-server && make install clean
 +
 
 +
===Setup===
  
 
copy /usr/local/etc/dhcpd.conf.sample to /usr/local/etc/dhcpd.conf
 
copy /usr/local/etc/dhcpd.conf.sample to /usr/local/etc/dhcpd.conf
  
edit /usr/local/etc/dhcpd.conf and make sure it has these lines in it.
+
edit /usr/local/etc/dhcpd.conf aas apropriate:.
 
<pre>
 
<pre>
 
# dhcpd.conf
 
# dhcpd.conf
Line 33: Line 36:
 
#option domain-name "example.org";
 
#option domain-name "example.org";
 
#option domain-name-servers ns1.example.org, ns2.example.org;
 
#option domain-name-servers ns1.example.org, ns2.example.org;
 
+
# lease times are measured in seconds:
 
default-lease-time 3600;
 
default-lease-time 3600;
 
max-lease-time 86400;
 
max-lease-time 86400;
Line 43: Line 46:
 
# ad-hoc DNS update scheme - set to "none" to disable dynamic DNS updates.
 
# ad-hoc DNS update scheme - set to "none" to disable dynamic DNS updates.
 
ddns-update-style none;
 
ddns-update-style none;
 
option root-path "192.168.1.1:/diskless_ro";
 
 
# lines added for pxeboot client
 
use-host-decl-names on;
 
next-server 192.168.1.1;
 
filename "pxeboot";
 
  
 
# Use this to send dhcp log messages to a different log file (you also
 
# Use this to send dhcp log messages to a different log file (you also
Line 57: Line 53:
 
# No service will be given on this subnet, but declaring it helps the
 
# No service will be given on this subnet, but declaring it helps the
 
# DHCP server to understand the network topology.
 
# DHCP server to understand the network topology.
 
  
 
# This is a very basic subnet declaration.
 
# This is a very basic subnet declaration.
Line 66: Line 61:
 
</pre>
 
</pre>
  
Create the leases file
+
===Create the leases file===
 
<pre>
 
<pre>
 
# touch /var/db/dhcpd.leases
 
# touch /var/db/dhcpd.leases
Line 72: Line 67:
  
  
Restart the daemon
+
===Restart the daemon===
 
<pre>
 
<pre>
 
# killall dhcpd
 
# killall dhcpd
Line 79: Line 74:
  
  
 +
===Setup to run on reboot===
 
Add to /etc/rc.conf
 
Add to /etc/rc.conf
 
<pre>
 
<pre>

Revision as of 11:25, 23 January 2007

Contents

DHCP

Dynamic Host Configuration Protocol. DHCP allows you to place machines on a network and configure many of their settings (network-wise) via a server that your host machine queries. Usually this is limited to what IP and DNS client information a host uses on the network, and this greatly increases an administrator's ability to configure a large number of hosts to use a network with minimal effort (as opposed to configuring each host individually.)

The service daemon on most *nix platforms is called dhcpd, the client application (if your *nix box is set up to use DHCP,) is usually dhclient.

Software

The most common unix implementation of the DHCP service is the ISC's DHCP; Microsoft has their own implementation, as does Sun Microsystems.

Configuration

(placeholder...needs info on hosts, networks, shared-networks and the different options)

DHCP - Install and setup

Installation

install through package:

# pkg_add -r isc-dhcp3-server

or ports:

# cd /usr/ports/nets/isc-dhcp3-server && make install clean

Setup

copy /usr/local/etc/dhcpd.conf.sample to /usr/local/etc/dhcpd.conf

edit /usr/local/etc/dhcpd.conf aas apropriate:.

# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
# lease times are measured in seconds: 
default-lease-time 3600;
max-lease-time 86400;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# ad-hoc DNS update scheme - set to "none" to disable dynamic DNS updates.
ddns-update-style none;

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

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

# This is a very basic subnet declaration.

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.10 192.168.1.20;
}

Create the leases file

# touch /var/db/dhcpd.leases


Restart the daemon

# killall dhcpd
# dhcpd


Setup to run on reboot

Add to /etc/rc.conf

dhcpd_enable="YES"

Problems starting dhcpd

Errors when trying to start

NOTE: This problem was found on this architecture, but may apply to others.

dhcp-1# uname -a
FreeBSD dhcp-1.one.example.com 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Thu Nov  3 09:36:13 UTC 2005   
root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC  i386
dhcp-1#
dhcp-1# /usr/local/etc/rc.d/isc-dhcpd.sh start
chown: dhcpd: Invalid argument
/usr/local/etc/rc.d/isc-dhcpd.sh: WARNING: unable to change permissions of /var/run/dhcpd
/usr/local/etc/rc.d/isc-dhcpd.sh: WARNING: safe_run: chown dhcpd:dhcpd /var/db/dhcpd
/usr/local/etc/rc.d/isc-dhcpd.sh: WARNING: unable to change permissions of /var/db/dhcpd
chown: dhcpd: Invalid argument
/usr/local/etc/rc.d/isc-dhcpd.sh: WARNING: unable to change permissions of /var/db/dhcpd/dhcpd.leases
Starting dhcpd.
dhcp-1#

Find out if dhcpd is running

dhcp-1# ps -auwx | grep dhcp
root     94818  0.0  0.6  2188  1536  ??  Is   15Jan07   0:00.05 /usr/local/sbin/dhcpd
root     24289  0.0  1.1  3892  2612  p0  RV    6:22AM   0:00.00 grep dhcp (csh)

Stop dhcpd (if running)

dhcp-1# kill -9 94818

Verify that dhcpd has been stopped

dhcp-1# ps -auwx | grep dhcp
root     24293  0.0  0.1   348   208  p0  R+    6:22AM   0:00.00 grep dhcp

Fix the problem

dhcp-1# /usr/local/etc/rc.d/isc-dhcpd.sh install
Added group "dhcpd".
Added user "dhcpd".
dhcp-1# 

Start dhcpd normally

dhcp-1# /usr/local/etc/rc.d/isc-dhcpd.sh start
Starting dhcpd.
dhcp-1#
Personal tools