{
    "mode": "man",
    "parameter": "dhcp-eval",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/dhcp-eval/5/json",
    "generated": "2026-06-17T19:12:57Z",
    "sections": {
        "NAME": {
            "content": "dhcp-eval - ISC DHCP conditional evaluation\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  Internet  Systems  Consortium DHCP client and server both provide the ability to perform\nconditional behavior depending on the contents of packets they receive.  The syntax for spec‐\nifying this conditional behaviour is documented here.\n",
            "subsections": [
                {
                    "name": "REFERENCE: CONDITIONAL BEHAVIOUR",
                    "content": "Conditional  behaviour  may be  specified using the if statement and the else or elsif state‐\nments or the switch and case statements.  A conditional statement can appear anywhere that  a\nregular  statement  (e.g.,  an option statement) can appear, and can enclose one or more such\nstatements.\n"
                },
                {
                    "name": "CONDITIONAL BEHAVIOUR: IF",
                    "content": "A typical conditional if statement in a server might be:\n\nif option dhcp-user-class = \"accounting\" {\nmax-lease-time 17600;\noption domain-name \"accounting.example.org\";\noption domain-name-servers ns1.accounting.example.org,\nns2.accounting.example.org;\n} elsif option dhcp-user-class = \"sales\" {\nmax-lease-time 17600;\noption domain-name \"sales.example.org\";\noption domain-name-servers ns1.sales.example.org,\nns2.sales.example.org;\n} elsif option dhcp-user-class = \"engineering\" {\nmax-lease-time 17600;\noption domain-name \"engineering.example.org\";\noption domain-name-servers ns1.engineering.example.org,\nns2.engineering.example.org;\n} else {\nmax-lease-time 600;\noption domain-name \"misc.example.org\";\noption domain-name-servers ns1.misc.example.org,\nns2.misc.example.org;\n}\n\nOn the client side, an example of conditional evaluation might be:\n\n# example.org filters DNS at its firewall, so we have to use their DNS\n# servers when we connect to their network.  If we are not at\n# example.org, prefer our own DNS server.\nif not option domain-name = \"example.org\" {\nprepend domain-name-servers 127.0.0.1;\n}\n\nThe if statement and the elsif continuation statement both take boolean expressions as  their\narguments.   That  is,  they take expressions that, when evaluated, produce a boolean result.\nIf the expression evaluates to true, then the statements enclosed in braces following the  if\nstatement  are  executed,  and all subsequent elsif and else clauses are skipped.  Otherwise,\neach subsequent elsif clause's expression is checked, until an elsif  clause  is  encountered\nwhose  test evaluates to true.  If such a clause is found, the statements in braces following\nit are executed, and then any subsequent elsif and else clauses are skipped.  If all  the  if\nand  elsif  clauses are checked but none of their expressions evaluate true, then if there is\nan else clause, the statements enclosed in braces following the else are evaluated.   Boolean\nexpressions that evaluate to null are treated as false in conditionals.\n"
                },
                {
                    "name": "CONDITIONAL BEHAVIOUR: SWITCH",
                    "content": "The above example can be rewritten using a switch construct as well.\n\nswitch (option dhcp-user-class) {\ncase \"accounting\":\nmax-lease-time 17600;\noption domain-name \"accounting.example.org\";\noption domain-name-servers ns1.accounting.example.org,\nns2.accounting.example.org;\ncase \"sales\":\nmax-lease-time 17600;\noption domain-name \"sales.example.org\";\noption domain-name-servers ns1.sales.example.org,\nns2.sales.example.org;\nbreak;\ncase \"engineering\":\nmax-lease-time 17600;\noption domain-name \"engineering.example.org\";\noption domain-name-servers ns1.engineering.example.org,\nns2.engineering.example.org;\nbreak;\ndefault:\nmax-lease-time 600;\noption domain-name \"misc.example.org\";\noption domain-name-servers ns1.misc.example.org,\nns2.misc.example.org;\nbreak;\n}\n\nThe  switch statement and the case statements can both be data expressions or numeric expres‐\nsions.  Within a switch statement they all must be the same type.  The server  evaluates  the\nexpression  from  the  switch  statement  and then it evaluates the expressions from the case\nstatements until it finds a match.\n\nIf it finds a match it starts executing statements from that case until the next break state‐\nment.   If it doesn't find a match it starts from the default statement and again proceeds to\nthe next break statement.  If there is no match and no default it does nothing.\n"
                }
            ]
        },
        "BOOLEAN EXPRESSIONS": {
            "content": "The following is the current list of boolean expressions that are supported by the DHCP  dis‐\ntribution.\n\ndata-expression-1 = data-expression-2\n\nThe  = operator compares the values of two data expressions, returning true if they are the\nsame, false if they are not.  If either the left-hand side or the right-hand side are null,\nthe result is also null.\n\ndata-expression-1 ~= data-expression-2 data-expression-1 ~~ data-expression-2\n\nThe  ~=  and ~~ operators (not available on all systems) perform extended regex(7) matching\nof the values of two data expressions, returning true if data-expression-1 matches  against\nthe regular expression evaluated by data-expression-2, or false if it does not match or en‐\ncounters some error.  If either the left-hand side or the right-hand side are null or empty\nstrings, the result is also false.  The ~~ operator differs from the ~= operator in that it\nis case-insensitive.\n\nboolean-expression-1 and boolean-expression-2\n\nThe and operator evaluates to true if the boolean expression on the left-hand side and  the\nboolean  expression  on the right-hand side both evaluate to true.  Otherwise, it evaluates\nto false.  If either the expression on the left-hand side or the expression on  the  right-\nhand side are null, the result is null.\n\nboolean-expression-1 or boolean-expression-2\n\nThe or operator evaluates to true if either the boolean expression on the left-hand side or\nthe boolean expression on the right-hand side evaluate to true.  Otherwise, it evaluates to\nfalse.   If either the expression on the left-hand side or the expression on the right-hand\nside are null, the result is null.\n\nnot boolean-expression\n\nThe not operator evaluates to true if boolean-expression evaluates to  false,  and  returns\nfalse  if  boolean-expression  evaluates to true.  If boolean-expression evaluates to null,\nthe result is also null.\n\nexists option-name\n\nThe exists expression returns true if the specified option  exists  in  the  incoming  DHCP\npacket being processed.",
            "subsections": [
                {
                    "name": "known",
                    "content": "The  known expression returns true if the client whose request is currently being processed\nis known - that is, if there's a host declaration for it."
                },
                {
                    "name": "static",
                    "content": "The static expression returns true if the lease assigned to the  client  whose  request  is\ncurrently being processed is derived from a static address assignment.\n"
                }
            ]
        },
        "DATA EXPRESSIONS": {
            "content": "Several  of  the  boolean  expressions above depend on the results of evaluating data expres‐\nsions.  A list of these expressions is provided here.\n\nsubstring (data-expr, offset, length)\n\nThe substring operator evaluates the data expression and returns the substring of  the  re‐\nsult  of that evaluation that starts offset bytes from the beginning, continuing for length\nbytes.  Offset and length are both numeric expressions.  If  data-expr,  offset  or  length\nevaluate  to null, then the result is also null.  If offset is greater than or equal to the\nlength of the evaluated data, then a zero-length data string is  returned.   If  length  is\ngreater  then  the  remaining length of the evaluated data after offset, then a data string\ncontaining all data from offset to the end of the evaluated data is returned.\n\nsuffix (data-expr, length)\n\nThe suffix operator evaluates data-expr and returns the last length bytes of the result  of\nthat evaluation.  Length is a numeric expression.  If data-expr or length evaluate to null,\nthen the result is also null.  If suffix evaluates to a number greater than the  length  of\nthe evaluated data, then the evaluated data is returned.\n\nlcase (data-expr)\n\nThe  lcase function returns the result of evaluating data-expr converted to lower case.  If\ndata-expr evaluates to null, then the result is also null.\n\nucase (data-expr)\n\nThe ucase function returns the result of evaluating data-expr converted to upper case.   If\ndata-expr evaluates to null, then the result is also null.\n\noption option-name\n\nThe option operator returns the contents of the specified option in the packet to which the\nserver is responding.\n\nconfig-option option-name\n\nThe config-option operator returns the value for the specified option that the DHCP  client\nor server has been configured to send.\n",
            "subsections": [
                {
                    "name": "gethostname()",
                    "content": "The gethostname() function returns a data string whose contents are a character string, the\nresults of calling gethostname() on the local system with a size limit of  255  bytes  (not\nincluding NULL terminator).  This can be used for example to configure dhclient to send the\nlocal hostname without knowing the local hostname at the time dhclient.conf is written.\n"
                },
                {
                    "name": "hardware",
                    "content": "The hardware operator returns a data string whose first element is the type of network  in‐\nterface  indicated  in  packet being considered, and whose subsequent elements are client's\nlink-layer address.  If there is no packet, or if the RFC2131 hlen field is  invalid,  then\nthe  result  is  null.   Hardware types include ethernet (1), token-ring (6), and fddi (8).\nHardware types are specified by the IETF, and details on how the type numbers  are  defined\ncan  be found in RFC2131 (in the ISC DHCP distribution, this is included in the doc/ subdi‐\nrectory).\n\npacket (offset, length)\n\nThe packet operator returns the specified portion of the packet being considered,  or  null\nin contexts where no packet is being considered.  Offset and length are applied to the con‐\ntents packet as in the substring operator.\n\nstring\n\nA string, enclosed in quotes, may be specified as a data expression, and returns  the  text\nbetween  the quotes, encoded in ASCII.  The backslash ('\\') character is treated specially,\nas in C programming: '\\t' means TAB, '\\r' means carriage return, '\\n'  means  newline,  and\n'\\b'  means  bell.  Any octal value can be specified with '\\nnn', where nnn is any positive\noctal number less than 0400.  Any hexadecimal value can be specified with '\\xnn', where  nn\nis any positive hexadecimal number less than or equal to 0xff.\n\ncolon-separated hexadecimal list\n\nA list of hexadecimal octet values, separated by colons, may be specified as a data expres‐\nsion.\n\nconcat (data-expr1, ..., data-exprN)\nThe expressions are evaluated, and the results of each evaluation are concatenated  in  the\nsequence  that  the subexpressions are listed.  If any subexpression evaluates to null, the\nresult of the concatenation is null.\n\nreverse (numeric-expr1, data-expr2)\nThe two expressions are evaluated, and then the result of evaluating the data expression is\nreversed  in place, using hunks of the size specified in the numeric expression.  For exam‐\nple, if the numeric expression evaluates to four, and  the  data  expression  evaluates  to\ntwelve  bytes  of  data, then the reverse expression will evaluate to twelve bytes of data,\nconsisting of the last four bytes of the input data, followed by  the  middle  four  bytes,\nfollowed by the first four bytes.\n"
                },
                {
                    "name": "leased-address",
                    "content": "In  any  context  where the client whose request is being processed has been assigned an IP\naddress, this data expression returns that IP address.  In any  context  where  the  client\nwhose  request is being processed has not been assigned an ip address, if this data expres‐\nsion is found in executable statements executed on that client's behalf, a log message  in‐\ndicating  \"there  is  no lease associated with this client\" is syslogged to the debug level\n(this is considered dhcpd.conf debugging information).\n\nbinary-to-ascii (numeric-expr1, numeric-expr2, data-expr1, data-expr2)\nConverts the result of evaluating data-expr2 into a text string containing one  number  for\neach  element  of  the  result of evaluating data-expr2.  Each number is separated from the\nother by the result of evaluating data-expr1.  The result of evaluating numeric-expr1 spec‐\nifies  the  base  (2 through 16) into which the numbers should be converted.  The result of\nevaluating numeric-expr2 specifies the width in bits of each number, which may be either 8,\n16 or 32.\n\nAs  an  example  of  the preceding three types of expressions, to produce the name of a PTR\nrecord for the IP address being assigned to a client, one could write the following expres‐\nsion:\n\nconcat (binary-to-ascii (10, 8, \".\",\nreverse (1, leased-address)),\n\".in-addr.arpa.\");\n\n\nencode-int (numeric-expr, width)\nNumeric-expr  is  evaluated and encoded as a data string of the specified width, in network\nbyte order (most significant byte first).  If the numeric expression evaluates to the  null\nvalue, the result is also null.\n\npick-first-value (data-expr1 [ ... exprn ] )\nThe  pick-first-value function takes any number of data expressions as its arguments.  Each\nexpression is evaluated, starting with the first in the list, until an expression is  found\nthat  does not evaluate to a null value.  That expression is returned, and none of the sub‐\nsequent expressions are evaluated.  If all expressions evaluate to a null value,  the  null\nvalue is returned.\n"
                },
                {
                    "name": "host-decl-name",
                    "content": "The  host-decl-name  function  returns  the  name  of the host declaration that matched the\nclient whose request is currently being processed, if any.  If no host declaration matched,\nthe result is the null value.\n"
                }
            ]
        },
        "NUMERIC EXPRESSIONS": {
            "content": "Numeric  expressions  are  expressions  that evaluate to an integer.  In general, the maximum\nsize of such an integer should not be assumed to be representable in fewer than 32 bits,  but\nthe precision of such integers may be more than 32 bits.\n\nIn  addition  to the following operators several standard math functions are available.  They\nare:\noperation    symbol\nadd            +\nsubtract       -\ndivide         /\nmultiply       *\nmodulus        %\nbitwise and    &\nbitwise or     |\nbitwise xor    ^\n\nextract-int (data-expr, width)\n\nThe extract-int operator extracts an integer value in network byte order from the result of\nevaluating the specified data expression.  Width is the width in bits of the integer to ex‐\ntract.  Currently, the only supported widths are 8, 16 and 32.  If the  evaluation  of  the\ndata  expression  doesn't  provide  sufficient  bits to extract an integer of the specified\nsize, the null value is returned.\n",
            "subsections": [
                {
                    "name": "lease-time",
                    "content": "The duration of the current lease - that is, the difference between the  current  time  and\nthe time that the lease expires.\n\nnumber\n\nAny  number  between  zero and the maximum representable size may be specified as a numeric\nexpression.\n"
                },
                {
                    "name": "client-state",
                    "content": "The current state of the client instance being processed.  This  is  only  useful  in  DHCP\nclient configuration files.  Possible values are:\n\n• Booting  -  DHCP  client  is in the INIT state, and does not yet have an IP address.  The\nnext message transmitted will be a DHCPDISCOVER, which will be broadcast.\n\n• Reboot - DHCP client is in the INIT-REBOOT state.  It has an IP address, but is  not  yet\nusing it.  The next message to be transmitted will be a DHCPREQUEST, which will be broad‐\ncast.  If no response is heard, the client will bind to its address and move to the BOUND\nstate.\n\n• Select  -  DHCP client is in the SELECTING state - it has received at least one DHCPOFFER\nmessage, but is waiting to see if it may receive  other  DHCPOFFER  messages  from  other\nservers.  No messages are sent in the SELECTING state.\n\n• Request - DHCP client is in the REQUESTING state - it has received at least one DHCPOFFER\nmessage, and has chosen which one it will request.  The next message to be sent will be a\nDHCPREQUEST message, which will be broadcast.\n\n• Bound - DHCP client is in the BOUND state - it has an IP address.  No messages are trans‐\nmitted in this state.\n\n• Renew - DHCP client is in the RENEWING state - it has an IP address,  and  is  trying  to\ncontact  the  server to renew it.  The next message to be sent will be a DHCPREQUEST mes‐\nsage, which will be unicast directly to the server.\n\n• Rebind - DHCP client is in the REBINDING state - it has an IP address, and is  trying  to\ncontact any server to renew it.  The next message to be sent will be a DHCPREQUEST, which\nwill be broadcast.\n"
                },
                {
                    "name": "REFERENCE: ACTION EXPRESSIONS",
                    "content": "log (priority, data-expr)\n\nLogging statements may be used to send information to the  standard  logging  channels.   A\nlogging  statement includes an optional priority (fatal, error, info, or debug), and a data\nexpression.\n\nLogging statements take only a single data expression argument, so if you  want  to  output\nmultiple data values, you will need to use the concat operator to concatenate them.\n\nexecute (command-path [, data-expr1, ... data-exprN]);\n\nThe  execute  statement  runs  an external command.  The first argument is a string literal\ncontaining the name or path of the command to run.  The other arguments,  if  present,  are\neither string literals or data- expressions which evaluate to text strings, to be passed as\ncommand-line arguments to the command.\n\nexecute is synchronous; the program will block until the external  command  being  run  has\nfinished.   Please  note  that lengthy program execution (for example, in an \"on commit\" in\ndhcpd.conf) may result in bad performance and timeouts.  Only  external  applications  with\nvery short execution times are suitable for use.\n\nPassing  user-supplied  data  to an external application might be dangerous.  Make sure the\nexternal application checks input buffers for  validity.   Non-printable  ASCII  characters\nwill  be converted into dhcpd.conf language octal escapes (\"\\nnn\"), make sure your external\ncommand handles them as such.\n\nIt is possible to use the execute statement in any context, not only on events.  If you put\nit  in a regular scope in the configuration file you will execute that command every time a\nscope is evaluated.\n"
                },
                {
                    "name": "parse-vendor-option;",
                    "content": "The parse-vendor-option statement attempts to parse a vendor option (code 43).  It is  only\nuseful  while processing a packet on the server and requires that the administrator has al‐\nready used the vendor-option-space statement to select a valid vendor space.\n\nThis functionality may be used if the server needs to take different actions  depending  on\nthe  values the client placed in the vendor option and the sub-options are not at fixed lo‐\ncations.  It is handled as an action to allow an administrator to examine the incoming  op‐\ntions and choose the correct vendor space.\n"
                },
                {
                    "name": "REFERENCE: DYNAMIC DNS UPDATES",
                    "content": "See the dhcpd.conf and dhclient.conf man pages for more information about DDNS.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "dhcpd.conf(5),  dhcpd.leases(5),  dhclient.conf(5),  dhcp-options(5),  dhcpd(8), dhclient(8),\nRFC2132, RFC2131.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Information about Internet Systems Consortium can be found at https://www.isc.org.\n\n\n\ndhcp-eval(5)",
            "subsections": []
        }
    },
    "summary": "dhcp-eval - ISC DHCP conditional evaluation",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "dhcpd.conf",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/dhcpd.conf/5/json"
        },
        {
            "name": "dhcpd.leases",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/dhcpd.leases/5/json"
        },
        {
            "name": "dhclient.conf",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/dhclient.conf/5/json"
        },
        {
            "name": "dhcp-options",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/dhcp-options/5/json"
        },
        {
            "name": "dhcpd",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/dhcpd/8/json"
        },
        {
            "name": "dhclient",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/dhclient/8/json"
        }
    ]
}