📄 dhcp-eval.5
字号:
.\" $Id: dhcp-eval.5,v 1.17.2.7 2004/06/10 17:59:15 dhankins Exp $.\".\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC").\" Copyright (c) 1996-2003 by Internet Software Consortium.\".\" Permission to use, copy, modify, and distribute this software for any.\" purpose with or without fee is hereby granted, provided that the above.\" copyright notice and this permission notice appear in all copies..\".\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE..\".\" Internet Systems Consortium, Inc..\" 950 Charter Street.\" Redwood City, CA 94063.\" <info@isc.org>.\" http://www.isc.org/.\".\" This software has been written for Internet Systems Consortium.\" by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc..\" To learn more about Internet Systems Consortium, see.\" ``http://www.isc.org/''. To learn more about Vixie Enterprises,.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see.\" ``http://www.nominum.com''..TH dhcp-eval 5.SH NAMEdhcp-eval - ISC DHCP conditional evaluation.SH DESCRIPTIONThe Internet Systems Consortium DHCP client and server both providethe ability to perform conditional behavior depending on the contentsof packets they receive. The syntax for specifying this conditionalbehaviour is documented here..SH REFERENCE: CONDITIONAL BEHAVIOURConditional behaviour is specified using the if statement and the elseor elsif statements. A conditional statement can appear anywherethat a regular statement (e.g., an option statement) can appear, andcan enclose one or more such statements. A typical conditionalstatement in a server might be:.PP.nfif option dhcp-user-class = "accounting" { max-lease-time 17600; option domain-name "accounting.example.org"; option domain-name-servers ns1.accounting.example.org, ns2.accounting.example.org;} elsif option dhcp-user-class = "sales" { max-lease-time 17600; option domain-name "sales.example.org"; option domain-name-servers ns1.sales.example.org, ns2.sales.example.org;} elsif option dhcp-user-class = "engineering" { max-lease-time 17600; option domain-name "engineering.example.org"; option domain-name-servers ns1.engineering.example.org, ns2.engineering.example.org;} else { max-lease-time 600; option domain-name "misc.example.org"; option domain-name-servers ns1.misc.example.org, ns2.misc.example.org;}.fi.PPOn the client side, an example of conditional evaluation might be:.PP.nf# example.org filters DNS at its firewall, so we have to use their DNS# servers when we connect to their network. If we are not at# example.org, prefer our own DNS server.if not option domain-name = "example.org" { prepend domain-name-servers 127.0.0.1;}.fi .PPThe.B ifstatement and the.B elsifcontinuation statement both take boolean expressions as theirarguments. That is, they take expressions that, when evaluated,produce a boolean result. If the expression evaluates to true, thenthe statements enclosed in braces following the .B ifstatement are executed, and all subsequent.B elsifand.B elseclauses are skipped. Otherwise, each subsequent .B elsifclause's expression is checked, until an elsif clause is encounteredwhose test evaluates to true. If such a clause is found, thestatements in braces following it are executed, and then anysubsequent.B elsifand.B elseclauses are skipped. If all the .B ifand.B elsifclauses are checked but noneof their expressions evaluate true, then if there is an.B elseclause, the statements enclosed in braces following the.B elseare evaluated. Boolean expressions that evaluate to null aretreated as false in conditionals..SH BOOLEAN EXPRESSIONSThe following is the current list of boolean expressions that aresupported by the DHCP distribution..PP.I data-expression-1 \fB=\fI data-expression-2\fR.RS 0.25i.PPThe \fB=\fR operator compares the values of two data expressions,returning true if they are the same, false if they are not. Ifeither the left-hand side or the right-hand side are null, theresult is also null..RE.PP.I boolean-expression-1 \fBand\fI boolean-expression-2\fR.PP.RS 0.25iThe \fBand\fR operator evaluates to true if the boolean expression onthe left-hand side and the boolean expression on the right-hand sideboth evaluate to true. Otherwise, it evaluates to false. If eitherthe expression on the left-hand side or the expression on theright-hand side are null, the result is null..RE.PP.I boolean-expression-1 \fBor\fI boolean-expression-2\fR.PP.RS 0.25iThe \fBor\fR operator evaluates to true if either the booleanexpression on the left-hand side or the boolean expression on theright-hand side evaluate to true. Otherwise, it evaluates to false.If either the expression on the left-hand side or the expression onthe right-hand side are null, the result is null..RE.PP.B not \fIboolean-expression.PP.RS 0.25iThe \fBnot\fR operator evaluates to true if \fIboolean-expression\fRevaluates to false, and returns false if \fIboolean-expression\fR evaluatesto true. If \fIboolean-expression\fR evaluates to null, the resultis also null..RE.PP.B exists \fIoption-name\fR.PP.RS 0.25iThe \fBexists\fR expression returns true if the specified optionexists in the incoming DHCP packet being processed..RE.B known.PP.RS 0.25iThe \fBknown\fR expression returns true if the client whose request iscurrently being processed is known - that is, if there's a hostdeclaration for it..RE.B static.PP.RS 0.25iThe \fBstatic\fR expression returns true if the lease assigned to theclient whose request is currently being processed is derived from a staticaddress assignment..RE.SH DATA EXPRESSIONSSeveral of the boolean expressions above depend on the results ofevaluating data expressions. A list of these expressions is providedhere..PP.B substring (\fIdata-expr\fB, \fIoffset\fB, \fIlength\fB)\fR.PP.RS 0.25iThe \fBsubstring\fR operator evaluates the data expression and returnsthe substring of the result of that evaluation that starts\fIoffset\fR bytes from the beginning, continuing for \fIlength\fRbytes. \fIOffset\fR and \fIlength\fR are both numeric expressions.If \fIdata-expr\fR, \fIoffset\fR or \fIlength\fR evaluate to null,then the result is also null. If \fIoffset\fR is greater than orequal to the length of the evaluated data, then a zero-length datastring is returned. If \fIlength\fI is greater then the remaininglength of the evaluated data after \fIoffset\fR, then a data stringcontaining all data from \fIoffset\fR to the end of the evaluated datais returned..RE.PP.B suffix (\fIdata-expr\fB, \fIlength\fB)\fR.PP.RS 0.25iThe \fBsuffix\fR operator evaluates \fIdata-expr\fR and returns thelast \fIlength\fR bytes of the result of that evaluation. \fILength\fRis a numeric expression. If \fIdata-expr\fR or \fIlength\fR evaluateto null, then the result is also null. If \fIsuffix\fR evaluates to anumber greater than the length of the evaluated data, then theevaluated data is returned..RE.PP.B option \fIoption-name\fR.PP.RS 0.25iThe \fBoption\fR operator returns the contents of the specified option inthe packet to which the server is responding..RE.PP.B config-option \fIoption-name\fR.PP.RS 0.25iThe \fBconfig-option\fR operator returns the value for the specified optionthat the DHCP client or server has been configured to send..RE.PP.B hardware.PP.RS 0.25iThe \fBhardware\fR operator returns a data string whose first elementis the type of network interface indicated in packet being considered,and whose subsequent elements are client's link-layer address. Ifthere is no packet, or if the RFC2131 \fIhlen\fR field is invalid,then the result is null. Hardware types include ethernet (1),token-ring (6), and fddi (8). Hardware types are specified by theIETF, and details on how the type numbers are defined can be found inRFC2131 (in the ISC DHCP distribution, this is included in the doc/subdirectory)..RE.PP.B packet (\fIoffset\fB, \fIlength\fB)\fR.PP.RS 0.25iThe \fBpacket\fR operator returns the specified portion of the packetbeing considered, or null in contexts where no packet is being
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -