📄 network-dhcp.html
字号:
compiled into your kernel. To do this, add <var class="LITERAL">device bpf</var> (<varclass="LITERAL">pseudo-device bpf</var> under FreeBSD 4.X) to your kernelconfiguration file, and rebuild the kernel. For more information about building kernels,see <a href="kernelconfig.html">Chapter 8</a>.</p><p>The <tt class="DEVICENAME">bpf</tt> device is already part of the <ttclass="FILENAME">GENERIC</tt> kernel that is supplied with FreeBSD, so you do not need tocreate a custom kernel in order to get DHCP working.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Those who are particularly security conscious should note that <ttclass="DEVICENAME">bpf</tt> is also the device that allows packet sniffers to workcorrectly (although such programs still need privileged access). <ttclass="DEVICENAME">bpf</tt> <span class="emphasis"><i class="EMPHASIS">is</i></span>required to use DHCP, but if you are very sensitive about security, you probably shouldnot include <tt class="DEVICENAME">bpf</tt> in your kernel purely because you expect touse DHCP at some point in the future.</p></blockquote></div><p>The next thing that you will need to do is edit the sample <ttclass="FILENAME">dhcpd.conf</tt> which was installed by the <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/net/isc-dhcp3-server/pkg-descr"><ttclass="FILENAME">net/isc-dhcp3-server</tt></a> port. By default, this will be <ttclass="FILENAME">/usr/local/etc/dhcpd.conf.sample</tt>, and you should copy this to <ttclass="FILENAME">/usr/local/etc/dhcpd.conf</tt> before proceeding to make changes.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN34657" name="AEN34657">23.5.7.3 Configuring the DHCPServer</a></h3><p><tt class="FILENAME">dhcpd.conf</tt> is comprised of declarations regarding subnetsand hosts, and is perhaps most easily explained using an example :</p><pre class="PROGRAMLISTING">option domain-name "example.com";<a id="DOMAIN-NAME" name="DOMAIN-NAME"><imgsrc="./imagelib/callouts/1.png" hspace="0" vspace="0" border="0" alt="(1)" /></a>option domain-name-servers 192.168.4.100;<a id="DOMAIN-NAME-SERVERS"name="DOMAIN-NAME-SERVERS"><img src="./imagelib/callouts/2.png" hspace="0" vspace="0"border="0" alt="(2)" /></a>option subnet-mask 255.255.255.0;<a id="SUBNET-MASK" name="SUBNET-MASK"><imgsrc="./imagelib/callouts/3.png" hspace="0" vspace="0" border="0" alt="(3)" /></a>default-lease-time 3600;<a id="DEFAULT-LEASE-TIME" name="DEFAULT-LEASE-TIME"><imgsrc="./imagelib/callouts/4.png" hspace="0" vspace="0" border="0" alt="(4)" /></a>max-lease-time 86400;<a id="MAX-LEASE-TIME" name="MAX-LEASE-TIME"><imgsrc="./imagelib/callouts/5.png" hspace="0" vspace="0" border="0" alt="(5)" /></a>ddns-update-style none;<a id="DDNS-UPDATE-STYLE" name="DDNS-UPDATE-STYLE"><imgsrc="./imagelib/callouts/6.png" hspace="0" vspace="0" border="0" alt="(6)" /></a>subnet 192.168.4.0 netmask 255.255.255.0 { range 192.168.4.129 192.168.4.254;<a id="RANGE" name="RANGE"><imgsrc="./imagelib/callouts/7.png" hspace="0" vspace="0" border="0" alt="(7)" /></a> option routers 192.168.4.1;<a id="ROUTERS" name="ROUTERS"><imgsrc="./imagelib/callouts/8.png" hspace="0" vspace="0" border="0" alt="(8)" /></a>}host mailhost { hardware ethernet 02:03:04:05:06:07;<a id="HARDWARE" name="HARDWARE"><imgsrc="./imagelib/callouts/9.png" hspace="0" vspace="0" border="0" alt="(9)" /></a> fixed-address mailhost.example.com;<a id="FIXED-ADDRESS" name="FIXED-ADDRESS"><imgsrc="./imagelib/callouts/10.png" hspace="0" vspace="0" border="0" alt="(10)" /></a>}</pre><div class="CALLOUTLIST"><dl compact="COMPACT"><dt><a href="network-dhcp.html#DOMAIN-NAME"><img src="./imagelib/callouts/1.png"hspace="0" vspace="0" border="0" alt="(1)" /></a></dt><dd>This option specifies the domain that will be provided to clients as the defaultsearch domain. See <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=resolv.conf&sektion=5"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">resolv.conf</span>(5)</span></a> formore information on what this means.</dd><dt><a href="network-dhcp.html#DOMAIN-NAME-SERVERS"><img src="./imagelib/callouts/2.png"hspace="0" vspace="0" border="0" alt="(2)" /></a></dt><dd>This option specifies a comma separated list of DNS servers that the client shoulduse.</dd><dt><a href="network-dhcp.html#SUBNET-MASK"><img src="./imagelib/callouts/3.png"hspace="0" vspace="0" border="0" alt="(3)" /></a></dt><dd>The netmask that will be provided to clients.</dd><dt><a href="network-dhcp.html#DEFAULT-LEASE-TIME"><img src="./imagelib/callouts/4.png"hspace="0" vspace="0" border="0" alt="(4)" /></a></dt><dd>A client may request a specific length of time that a lease will be valid. Otherwisethe server will assign a lease with this expiry value (in seconds).</dd><dt><a href="network-dhcp.html#MAX-LEASE-TIME"><img src="./imagelib/callouts/5.png"hspace="0" vspace="0" border="0" alt="(5)" /></a></dt><dd>This is the maximum length of time that the server will lease for. Should a clientrequest a longer lease, a lease will be issued, although it will only be valid for <varclass="LITERAL">max-lease-time</var> seconds.</dd><dt><a href="network-dhcp.html#DDNS-UPDATE-STYLE"><img src="./imagelib/callouts/6.png"hspace="0" vspace="0" border="0" alt="(6)" /></a></dt><dd>This option specifies whether the DHCP server should attempt to update DNS when alease is accepted or released. In the ISC implementation, this option is <spanclass="emphasis"><i class="EMPHASIS">required</i></span>.</dd><dt><a href="network-dhcp.html#RANGE"><img src="./imagelib/callouts/7.png" hspace="0"vspace="0" border="0" alt="(7)" /></a></dt><dd>This denotes which IP addresses should be used in the pool reserved for allocating toclients. IP addresses between, and including, the ones stated are handed out toclients.</dd><dt><a href="network-dhcp.html#ROUTERS"><img src="./imagelib/callouts/8.png" hspace="0"vspace="0" border="0" alt="(8)" /></a></dt><dd>Declares the default gateway that will be provided to clients.</dd><dt><a href="network-dhcp.html#HARDWARE"><img src="./imagelib/callouts/9.png" hspace="0"vspace="0" border="0" alt="(9)" /></a></dt><dd>The hardware MAC address of a host (so that the DHCP server can recognize a host whenit makes a request).</dd><dt><a href="network-dhcp.html#FIXED-ADDRESS"><img src="./imagelib/callouts/10.png"hspace="0" vspace="0" border="0" alt="(10)" /></a></dt><dd>Specifies that the host should always be given the same IP address. Note that using ahostname is correct here, since the DHCP server will resolve the hostname itself beforereturning the lease information.</dd></dl></div><p>Once you have finished writing your <tt class="FILENAME">dhcpd.conf</tt>, you canproceed to start the server by issuing the following command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">/usr/local/etc/rc.d/isc-dhcpd.sh start</kbd></pre><p>Should you need to make changes to the configuration of your server in the future, itis important to note that sending a <var class="LITERAL">SIGHUP</var> signal to <bclass="APPLICATION">dhcpd</b> does <span class="emphasis"><iclass="EMPHASIS">not</i></span> result in the configuration being reloaded, as it doeswith most daemons. You will need to send a <var class="LITERAL">SIGTERM</var> signal tostop the process, and then restart it using the command above.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN34711" name="AEN34711">23.5.7.4 Files</a></h3><ul><li><p><tt class="FILENAME">/usr/local/sbin/dhcpd</tt></p><p><b class="APPLICATION">dhcpd</b> is statically linked and resides in <ttclass="FILENAME">/usr/local/sbin</tt>. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=dhcpd&sektion=8&manpath=FreeBSD+Ports"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">dhcpd</span>(8)</span></a> manual pageinstalled with the port gives more information about <bclass="APPLICATION">dhcpd</b>.</p></li><li><p><tt class="FILENAME">/usr/local/etc/dhcpd.conf</tt></p><p><b class="APPLICATION">dhcpd</b> requires a configuration file, <ttclass="FILENAME">/usr/local/etc/dhcpd.conf</tt> before it will start providing service toclients. This file needs to contain all the information that should be provided toclients that are being serviced, along with information regarding the operation of theserver. This configuration file is described by the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=dhcpd.conf&sektion=5&manpath=FreeBSD+Ports"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">dhcpd.conf</span>(5)</span></a>manual page installed by the port.</p></li><li><p><tt class="FILENAME">/var/db/dhcpd.leases</tt></p><p>The DHCP server keeps a database of leases it has issued in this file, which iswritten as a log. The manual page <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=dhcpd.leases&sektion=5&manpath=FreeBSD+Ports"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">dhcpd.leases</span>(5)</span></a>,installed by the port gives a slightly longer description.</p></li><li><p><tt class="FILENAME">/usr/local/sbin/dhcrelay</tt></p><p><b class="APPLICATION">dhcrelay</b> is used in advanced environments where one DHCPserver forwards a request from a client to another DHCP server on a separate network. Ifyou require this functionality, then install the <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/net/isc-dhcp3-relay/pkg-descr"><ttclass="FILENAME">net/isc-dhcp3-relay</tt></a> port. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=dhcrelay&sektion=8&manpath=FreeBSD+Ports"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">dhcrelay</span>(8)</span></a> manualpage provided with the port contains more detail.</p></li></ul></div></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="network-nis.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="network-dns.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Network Information System (NIS/YP)</td><td width="34%" align="center" valign="top"><a href="network-servers.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Domain Name System (DNS)</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting <<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>>.<br />For questions about this documentation, e-mail <<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>>.</small></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -