Entries in the [Settings] section
AddStandardEntries is a new setting in V2.3.4.
[Settings] AddStandardEntries=1 ; Default: 1
It allows to control the behaviour of the DHCP Server with respect to DNS_x, WINS_x and ROUTER_x entries in the replies from the server to the client. The default behaviour (AddStandardEntries=1) is to automatically add the standard values from the Windows configuration to the reply message. This is convenient, because it makes it unneccessary to repeat all the DNS_x, WINS_x and ROUTER_x settings that were already made in Windows IP configuration. If the server should not take the standard values from Windows, then set AddStandardEntries=0.
Associate the IP pools with the respective IP binds.
[Settings] AssociateBindsToPools=1 ; Default : 0
If the DHCP Server is configured to use more than one NIC with a separate subnet each (see Example 3 in the overview) then this entry associates the IPPOOL_x with the IPBIND_x. The two entries with the same number “x” belong together. Clients on subnet IPBIND_x get IP addresses assigned only from the pool defined by IPPOOL_x.
The default behavior (AssociateBindsToPools=0) is to view all IPPOOL_x as one big pool of IP addresses which can be assigned to any client regardless of the subnet IPBIND_x.
Setting ClearClientsOnStartup=1 basically removes all clients from the INI file every time the DHCP Server is started.
[Settings] ClearClientsOnStartup=1 ; Default : 0
This is not recommended in general usage but might be useful in special cases.
[Settings] ConfigureUnknownClients=1 ; Default: 1
ConfigureUnknownClients is available since V1.7. Setting this to 1 tells the DHCP server to automatically configure unknown clients. Since this is the default, there is no change to previous versions. If ConfigureUnknownClients is set to 0, then a client is assigned an IP address only if the client is already specified in the INI file. Note: Important difference to IgnoreUnknownClients. IgnoreUnknownClients only controls how the DHCP Server behaves when no IP address is assigned (declining request or keep quiet). What makes a client a “known client” is an existing entry in the INI file such as:
[00-01-02-03-04-05] ; mac address AutoConfig=1
[00-01-02-03-04-??] ; mac address with wildcards AutoConfig=1
[client-identifier] ; client identifier (option 61) AutoConfig=1
The Database setting allows to split the dhcpsrv.ini file into two parts. (Available since V1.7)
[Settings] Database=d:\database.ini ; Default : -
Part 1 is for everything in the [Settings] section. This stays in the dhcpsrv.ini file. All the rest [General], [General_x] or client section goes into the Database.ini file. This allows a clean distinction between real settings and configuration for the DHCP server and the IP assignment database in which the client configurations are managed.
New in V1.9.2: If no [General] or [General_x] section is found in the Database.ini file, then the dhcpsrv.ini config file is used for that instead.
If no Database setting is defined, then the DHCP server assumes that the database is part of the dhcpsrv.ini file.
The DeleteOnRelease setting is new in V1.9.
[Settings] DeleteOnRelease=0 ; Default: 1
It defines whether a client entry in the databse is deleted upon DHCPRELEASE, or not. The default behavior is to automatically delete the entry in the database. The effect is that when the same client comes back after some time and asks for an IP address, no information about it’s previous IP address is available. Even if the old IP address is available, it would most likely not being chosen. With DeleteOnRelease set to 0, the entry only gets an expired lease timestamp and can therefore be reactivated at a later time.
In addition to this the DeleteOnRelease setting also controls the bahvior for expired leases. When DeleteOnRelease is set then expired leases are also automatically deleted from the INI file same as DHCPRELEASE from client. This is new in V1.9.3 and is based on a timeout mechansim. The timeout is set to the time when the next client lease expires. This is updated every time a DHCP action is happening.
The EnableSendRawUnicast setting is new in V1.9.1.
[Settings] EnableSendRawUnicast=0 ; Default : 0
The DHCP protocol allows the client to specify a broadcast flag. If this flag is not set, then the DHCP server is asked to unicast the response. Unfortunatly, there is no standard mechanism based on the winsock programming interface that would allow the DHCP server to send unicasts solely based on mac address addressing scheme. In V1.9.1 the usage of the winpcap library got implemented. In situations where a unicast is required without having an IP address of the client at hand, the wpcap.dll function pcap_sendpacket is used. The EnableSendRawUnicast setting enables this functionality. Please set to 1 only if there are really problems with clients in that situation. Clients actually should be also fine with receiving responses as broadcast, which is the default behavior if EnableSendRawUnicast is not set or the wpcap dll is not installed. This has been tested with winpcap Version V4.1.1. Please also see the description of the OverwriteBroadcastFlag setting for even more advanced options to set.
ExpiredLeaseTimeout defines a time value in seconds.
[Settings] ExpiredLeaseTimeout=4294967 ; Approx. 49 days
The mechanism that checks expired leases is triggered by this. Regardless of when the next lease expires, the mechanism is scheduled at least in the time interval specified by ExpiredLeaseTimeout. This is useful when the INI file entries get changed manually and the DHCP server may not be aware of already expired leases. By this, the INI file gets cleaned up cyclically.
HBA provides a basic load balancing concept according to RFC3074. HBA stands for hash bucket allocation and defines whether the DHCP Server is responsible for a client or not. The HBA consists of 32 hex values separated by a single blank. Every hex number represents eight bits, one bit per hash bucket. The DHCP server calculates a hash value for every client that asks for an IP address. The hash value is between 0 and 255. If the correspondig HBA bit for that hash value is 1, then the client is serviced. If it is 0 then the client is not serviced. Please assume the following example:
[Settings] HBA=FF FF FF FF FF FF 00 00 FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
This restricts the DHCP Server to service clients whose hash value is 0 through 47 or 64 through 127. The server servicing the rest of the clients should have the exact opposite HBA. The HBA logic kicks in only for clients that are unknown (not yet in the INI file) to the DHCP Server. Clients who are already known are serviced regardless of the HBA.
[Settings] IgnoreUnknownClients=1 ; Default: 0
Setting this to 1 tells the DHCP server not to answer to requests from clients that are not configured in the client sections. DHCP requests from unknown clients are declined, if IgnoreUnknownClients is set to 0 (default).
[Settings] InstallAsService=2 ; Default: -
This is used internally by the DHCP Server to remember the checkbox “Don’t ask this question again” on startup of the software.
Binding to certain IP addresses (or NIC cards).
[Settings] IPBIND_0=22.214.171.124 ; Default: - IPBIND_1="Local Area Connection" ; name of connection IPBIND_2=192.168.2.1 … IPBIND_9=192.168.10.2
This restricts the DHCP server to bind only to certain LAN connections. All other IP addresses are ignored. This is very important if you want to restrict the DHCP server to particular cards in your computer. You have already two IP addresses, as soon as the computer is on the internet using a dial up connection.
The DHCP server will bind to all IP addresses if no IPBIND_x is found. IPBIND_0 to IPBIND_9 are supported.
Starting with V1.8 the value of an IPBIND_x entry can also be specified as a LAN connection name. These are the names Windows is using to specifiy network connections. In case a name based IPBIND_x is configured, then subnet mask, ip address and all other windows configured data such as DNS server addresses etc. are obtained automatically and don’t need to be explicitly specified in the ini file anymore. See also the AUTO feature in IPPOOL_x.
From version 1.5 on the auto configuration is supported:
[Settings] IPPOOL_0=126.96.36.199-90 IPPOOL_1=188.8.131.52-254 IPPOOL_2=AUTO
The above enables three IP pools for DHCP clients. Unknown clients are automatically configured by adding the appropriate client sections to the INI file. IP pools of size 1 (e.g. 184.108.40.206-78) are allowed and are very useful if you want to assign the same IP address to all clients.
The new feature in V1.8 is: AUTO. If AUTO instead of a numerical IP-Pool configuration is used then the IP Pool is automatically chosen to cover the complete IP Range based on the IPBIND_x IP address and the network mask. This works best together with a name based IPBIND_x configuration.
From V1.9 on the IPPOOL_x numerical IP-Pool definition is enhanced with a comma syntax. This allows to define IP pools such as:
This adds 220.127.116.11 and 18.104.22.168 to the IPPOOL_0.
Since V2.3.1 it is also possible to define a class A/B network by using IPPOOL_1=10.45.3.1-10.45.5.254. This defines, in accordance with the subnet mask, all IP addresses from 10.45.3.1 through 10.45.5.254 as the IP pool.
[Settings] IPRELAY_0=192.168.2.1 ; Default: - … IPRELAY_9=192.168.10.1
IPRELAY_x is the definition of the DHCP Server address where the relay agent sends all requests coming in from IPBIND_x. Please see the description in the INI file overview about relay agents to learn more. IPRELAY_x is supported since V2.0.
[Settings] IPSCOPE_0=string-expression ; Default: - … IPSCOPE_9=string-expression
IPSCOPE_n defines based on the client request if this scope matches or not. Continue reading →
[Settings] MINPACKETLENGTH=300 ; Default: 300
This option is new in V1.6 and allows to specify a minimum packet length that the DHCP server is supposed to respond with. Default is 300 bytes. Some clients were not happy with a too short response. The remainder of the packet is filled with 0.
[Settings] NAKMessage="Info text for DHCPNAK" ; Default: -
Since V2.2.1 NAKMessage allows to specify an info text that is added to DHCPNAK replies as option 56. This info text is visible in some DHCP clients. It is very rarely used and should usually be omitted. Default behavior if NAKMessage is not specified is to not add option 56 in the reply.
The DHCP Server automatically recognizes changes in the IP configuration in Windows. This is done based on the Windows API NotifyAddrChange. This API tells the DHCP Server when an IP configuration is changing. The DHCP Server acts on this by internally shutting down and restarting itself. Upon restart, the new configuration is used. In order to not shutdown and restart unneccessarily the DHCP Server uses a timeout mechanism to delay the shutdown after NotifyAddrChange events.
[Settings] NotifyTimeout=5000 ; Default: 1000 (milliseconds)
The default of this timeout is 1 second (1000 millisends). Some network cards are very slow and require a longer delay before they are actually ready to run. Set the NotifyTimeout value to a larger timeout period to compensate for this.
[Settings] ObeyParamReqList=0 ; Default: 0
ObeyParamReqList is new in V2.4.1. If set to 1, then the DHCP responses will only include options that the client requested in his option 55.
[Settings] OverwriteBroadcastFlag=0 ; Default: broadcast-flag as set by the client request
OverwriteBroadcastFlag is new in V1.9.1. It allows to overwrite the broadcast flag set by the client. (See also EnableSendRawUnicast setting). The default behavior if this setting is not present or commented out, is to act according to the DHCP specification. If OverwriteBroadcastFlag is present then the behavior is to always broadcast the response (= 0) or to always try to unicast the response first (= 1). If unicast fails, then the DHCP Server defaults to broadcast.
[Settings] PacketValidation=0 ; Default: 1
PacketValidation allows to switch off the packet validation routine that filters malformed DHCP requests. Added in V2.2. This setting exists only to bypass a too aggressive validation that falsly identifies correct requests as malformed.
[Settings] PADDING=0 ; Default: 0
PADDING is new in V1.8 and enables to add PAD bytes (0) after each DHCP option, if the next option would otherwise be stored at a non WORD aligned offset. Some older BOOTP clients require this.
In order to enable padding please set PADDING=1 in the [Settings] section.
Changing the port number for certain services in the DHCP server.
[Settings] PORT_53=53 ; Default: 53 (DNS) PORT_67=67 ; Default: 67 (DHCP) PORT_68=68 ; Default: 68 (DHCP) PORT_69=69 ; Default: 69 (TFTP) PORT_80=80 ; Default: 80 (HTTP)
These options are new in V1.6.5 and allows to customize the IP ports the DHCP Server is supposed to use. Default is 67 or 68 respectively. Port 53 is the default port for the DNS Server. Port 69 is the default port of the TFTP Server. Port 80 is the default port of the HTTP Server (available since V2.0). If no relay agent function is in use, then this setting has no effect.
Enabling advanced features of the relay agent.
[Settings] RelayAgentAdvanced=1 ; Default: 1
Since V2.1.3 this setting allows to alter the behavior of the relay agent. With RelayAgentAdvanced=0, the relay agent runs in a compatible mode and can be used in conjunction with other DHCP servers such as Windows 2003 Server. With the default setting of RelayAgentAdvanced=1, the relay agent adds option 82 to all requests. This allows the DHCP Server to distinguish between the link selection information and the address of the relay agent.
Controls the behavior of the DHCP Server when offering an IP address to the client. In case of ReserveByOffer=1, the client section is written to the INI file with a lease time of 1 second when answering with a DHCPOFFER message. In case of 0, no INI file entry is made at the time of offering an IP address. Only the actual assignment (reaction to DHCPREQUEST) of the IP address creates a client section. Of course, the lease time is updated upon assignment to the requested lease time.
[Settings] ReserveByOffer=0 ; Default: 1
This was an undocumented feature until V2.5.0.
Configure the sname field.
[Settings] ServerName=Name of server ; Default: Windows computer name
Since V2.4 it is possible to define the content of the sname (server name) field in the DHCP reply packets. The default is the computer name as it is configured in Windows (return value of Win32 API GetComputerName).
Customizing the service name.
[Settings] SERVICENAME=DHCP Server ; Default: DHCP Server SERVICEDISPLAYNAME=DHCP Server ; Default: DHCP Server
Since V1.9 the DHCP server supports customizing the service name entries. This is useful when the service is to be installed several times (different INI file needed) or in combination with an already existing DHCP server with the same service name.
Disabling balloon messages.
[Settings] ShowBalloonMessages=1 ; Default: 1
Since V1.7 the DHCP server shows balloon messages in the tray if run in application mode. This can be disabled by setting ShowBalloonMessages=0.
Limit the DHCP Server to one instance.
[Settings] SingleInstanceApp=1 ; Default: 0
Since V2.2.3 it is possible to limit the DHCP Server to one instance if run in application mode. If SingleInstanceApp is not configured or set to 0 then the server can be started multiple times. If set to 1 then the second instance will only show a dialog inidicating that it’s a second instance and will terminate after confirming the dialog box.
Enabling the Trace.
[Settings] Trace=1 ; Default: 0 TraceFile=c:\temp\dhcptrc.txt
You can switch the trace on by putting a Trace=1 entry into the [Settings] section. The trace file is called dhcptrc.txt and is written into the same folder as the dhcpsrv.exe and the dhcpsrv.ini files. I recommend to switch the trace on, if you encounter any problems and attach the trace file to the e-mail that you are sending to me to report it. If you want the trace to have a different name (and/or directory) then use TraceFile for that. Example:
[Settings] Trace=1 ; 1= enable, 0=disable TraceFile=c:\temp\dhcptrc.txt ; this is where the trace goes
If the TraceFile setting in not set then the default is dhcptrc.txt in the dhcpsrv.exe directory. TraceFile is a new feature in V1.5.2.
Customizing the tray icon.
[Settings] TRAYICON=someicon.ico ; Default: default icon
Since V2.1 it is possible to change the tray icon of the dhcp server. The default tray icon is still avaible as a default. You can either choose “None”, “Default” or a filename.
TRAYICON=Default ; use the built in default icon. TRAYICON=None ; use no icon at all.
To set the tray icon to NONE is not recommended because the process can only be stopped using task manager if there is no tray icon.
TRAYICON=filname.ico loads the given icon file as the try icon.
All this is of course only effective if dhcpsrv.exe is started as an application (not as a service). The intended purposes to choose the tray icon is to bo able to distinguish the processes in the tray in case you are running dhcpsrv.exe multiple times.
[Settings] UseClientID=1 ; Default: 0
If UseClientID is set to 1, then clients can be recognized based on their Option 61 specification “client-identifier”. Option 61 allows several client id formats. Two of them are supported by the DHCP Server: type=0 and type=1. Type 1 is treated as the mac address of the client and just uses the mac address given by option 61 instead of the chaddr field of the DHCP packet.
Type 0 is treated as an ascii string. The client section is created with the client identifier instead of the mac address. Also the manual specification of client sections need to be based on the client-idendifier, if UseClientID is set to 1. This option is new in V1.7.
Configure a VENDORCLASS.
[Settings] VENDORCLASS=MSFT 5.0 ; Default: -
If a VENDORCLASS is specified as an entry in the [Settings] section, then only clients with the same vendor class defined in their DHCP request get an IP address assigned.
Entries in the [DNS-Settings] section
The DEFAULTIPADDR setting is a very simple but effective security feature.
[DNS-Settings] DEFAULTIPADDR=192.168.17.18 ; Default: -
If DEFAULTIPADDR is not set then the DNS server serves everybody as expected with resolved names. If it is set, then requesters with an unknown IP address get always the default ip address as an answer to all name resolution requests. The intention of this feature is to forward all unknown clients to a predefined default address (e.g. a web server with registration facility). Since V1.9.3, this can be also defined on a per client basis. Please see AllowDNSQuery for details.
Please note that the PC running the DHCP server always resolves DNS requests regardless of the DEFAULTIPADDR setting.
EnableDNS enables the integrated Domain Name Service (DNS) functionality of the DHCP Server.
[DNS-Settings] EnableDNS=1 ; Default: 0
Forwarding DNS requests.
[DNS-Settings] FORWARD=192.168.2.1 ; Default: -
The FORWARD setting defines the IP address of one external DNS server that gets all the requests that the integrated DNS server can not answer. This feature is fairly rudimentary and works only with UDP.
Entries in the [TFTP-Settings] section
Enabling the TFTP function.
[TFTP-Settings] EnableTFTP=1 ; Default: 0
EnableTFTP enables the integrated Trivial File Transfer Protocol (TFTP) server functionality of the DHCP Server.
Controlling the TFTP blksize.
[TFTP-Settings] MaxBlockSize=1024 ; Default: - (whatever the client asks for)
The tftp protocol allows to negotiate the blksize. This is the number of bytes transfered between client and server in each packet. It has been shown that if the client asks for a blksize that is bigger than the MTU, that the tftp communication does not work. Therefore it is since V2.2.3 possible to limit the blksize on the server side. MaxBlockSize should be set to a value between 512 and the MTU.
The PortRange setting defines the ports the TFTP server will use for sending and receiving data.
[TFTP-Settings] PortRange=51000-51100 ; Default: AUTO
The default is AUTO and specifies that the port numbers are allocated automatically on demand as they are made available by windows sockets (winsock). This can be a problem with firewalls, because the port numbers can not be explicitly opened in the firewall if they are unknown at configuration time. Therefore it is possible to specify a range of ports like PortRange=51000-51100. This tells the TFTP function to select port numbers out of the given range for sending and receiving data. Please make sure that the specified port numbers are not confilicting with other network services running on the server.
Specifying the root for the TFTP server.
[TFTP-Settings] Root=c:\tftproot\ ; Default: -
Only files located in or under the given Root path are served by the tftp server. A tftp client request asking for a file x automatically translates to a file access to c:\tftproot\x.
Setting the TFTP Transfer window.
[TFTP-Settings] TransferWindow=1 ; Default: 4
The tftp-setting TransferWindow sets the maximum number of tftp data packets that are sent before an acknowledge is received. TFTP protocol standard behavior is achieved by setting TransferWindow=1. The default of 4 should increase TFTP performance by about 50%. In case of problems try to set to 1.
Allowing the TFTP server to write files.
[TFTP-Settings] WritePermission=1 ; Default: 0
If not set or set to 0 WritePermission is not granted. Tftp clients can not write files in this case.
Entries in the [HTTP-Settings] section
Define the content types along with the respective file extensions for the HTTP server.
[content-type] .htm=text/html ; Default: -
The http server knows the content-type definitions for .htm, .html, .css, .xsl, .jpg, .png, .gif, .ico, .xml and .txt. Additional file extensions and their respective content types can be specified in the [content-type] section.
Specifying a default file for error messages (404).
[HTTP-Settings] DefaultFile=showerr.html ; Default: -
The DefaultFile allows to specify a file whose content is returned instead of a 404 file not found message. This is a new feature in V2.3.3. In case the URL refers to a not existing file, then this file is fetched. If DefaultFile is not specified then the regular 404 file not found return occurs.
EnableHTTP enables the integrated HTTP Protocol server functionality of the DHCP Server.
[HTTP-Settings] EnableHTTP=1 ; Default: 0
Specifying the HTTP log file.
[HTTP-Settings] Logfile=c:\httplog.txt ; Default: -
The http server logs all activities in this file.
Specifying the root for the HTTP server.
[HTTP-Settings] Root=c:\httproot\ ; Default: -
Only files located in or under the given Root path are served by the http server. A Web browser request asking for a file x automatically translates to a file access to c:\httproot\x.
Entries in the [General], [General_x] or client section
AllowDNSQuery goes along with the built-in DNS functionality. A client who performs DNS queries that is not known to the DHCP Server (not in the ini file) can get a default IP address returned regardless of the name it wants to resolve. This is a security feature that limits the DNS function to known clients. Since V1.9.3 AllowDNSQuery defines this behavior on a per client basis. If AllowDNSQuery is set to 1 then the client can resolve names to IP addresses with DNS queries. If AllowDNSQuery is set to 0 then whatever is configured as DEFAULTIPADDR is returned for every name.
Please assume the following INI file:
[General] ... AllowDNSQuery=0 ... [DNS-Settings] EnableDNS=1 DEFAULTIPADDR=192.168.0.1 [00-00-00-00-00-01] IPADDR=192.168.0.10 Hostname=Computer_1 [00-00-00-00-00-02] IPADDR=192.168.0.11 Hostname=Computer_2 AllowDNSQuery=1
In this example, only Computer_2 will be able to resolve DNS queries to the real IP addresses. Computer_1 will observe that regardless of the name he wants to resolve, he will always get 192.168.0.1 in return.
The influence of AllowDNSQuery to the behavior is such that, whenever DEFAULTIPADDR is set, the DEFAULTIPADDR is returned when the requester is unknown (not listed in the INI file) or AllowDNSQuery is 0.
Case DEFAULTIPADDR AllowDNSQuery Requester RESULT 1 SET 1 known resolve IP 2 SET 1 unknown DEFAULTIPADDR 3 SET 0 known DEFAULTIPADDR 4 SET 0 unknown DEFAULTIPADDR 5 NOT SET 1 known resolve IP 6 NOT SET 1 unknown resolve IP 7 NOT SET 0 known resolve IP 8 NOT SET 0 unknown resolve IP
This entry marks a client section as being created by the DHCP Server (auto configuration). Don’t touch it.
Defining the BOOTFILE.
A string that typically defines the boot file which is fetched from a TFTP server by the client.
This entry sets the IP address of the DNS server. You can setup up to 10 DNS servers.
DNS_0=22.214.171.124 … DNS_9=192.168.2.1
This entry should define the domain name that is send to the client machine. This is in most cases the name of the domain or workgroup that your server machine is in.
Specifying the IP Address.
This is the IP address that has to be assigned to the client. This is the most important entry in the client section.
LeaseEnd is specified as number of seconds since midnight (00:00:00), January 1, 1970 and defines the time at which this particular IP address expires.
This entry is automatically created by the DHCP Server.
Lease times are important when a client requests an IP address and all addresses in the IP pool are already assigned to other clients. In that case the client whose lease time (LeaseEnd) has expired least recently is deleted from the INI file and the available IP address is used for the request.
Lease time in seconds (decimal value).
LEASETIME=3600 ; 1 hour Default: infinite
E.g. 86400 is the lease time for 1 day. Default is an infinite lease. The actual lease period for the clients IP address is the minimum of the configured LEASETIME and the lease duration the client is asking for.
“ClientPC” is send to the client as the hostname entry in the DHCP options.
This is supposed to be the name of the client machine. This entry doesn’t work with Windows clients, because they do not change the computer name.
IP address of the “next server”.
This is typically used to specify a TFTP server in the BOOTP protocol.
NODETYPE=8 ; Default: 8
Default: 8, which means hybrid. I’ve never used something else than 8.
Specifying the Router / Gateway
ROUTER_0=126.96.36.199 … ROUTER_9=192.168.2.1
This entry sets the IP address of the router or standard gateway. You can setup up to 10 routers by using the entries ROUTER_0 to ROUTER_9.
The subnet mask is usually common to all clients and should be placed in the general section. This has to be the same as the subnet mask of the server machine that is setup in your network settings.
WINS_0=188.8.131.52 … WINS_9=192.168.2.1
This entry sets the IP address of the WINS servers. You can setup up the 10 WINS servers using the entries WINS_0 to WINS_9.
Location of a proxy server (Web Proxy Auto Detection) used by Internet browsers to automatically detect proxy settings.
- Custom options
The DHCP server supports custom options in addition to the above options. This allows to specifiy all possible DHCP options in client and general sections. (New in V1.7)
The syntax for custom options is:
[00-01-02-03-04-6A] OPTION_nn="whatever text" ; text OPTION_nn=02:03:04:05 ; hex bytes OPTION_nn=192.168.2.1 ; IP address OPTION_nn= 01 "whatever text" ; combination of hex byte and text
nn is the option number (decimal) such as OPTION_66 for TFTP server IP address.
Please note that all the examples above have a trailing comment in each line. This is necessary and is not optional. The comment even if it is only the semi-colon (;) is needed.
OPTION_nn=”whatever text” ;
If there is no comment symbol at the end then the OPTION_nn setting will not be recognized correctly and is treated as malformed and therefore ignored.
The custom option syntax understands hex bytes as two digit values, IP addresses as a group of four decimal numbers seperated by ‘.’, and “text”. As seperators are allowed: blanks and colons (:). Two special syntax features make it easier to deal with custom options (available since V2.4). The first is the auto-len prefix for everything inside of parentheses (). You can group all data (hex bytes, IP addresses and text) as you whish and put parentheses around them. The resulting encoding will automatically prefix the data with a length field. An example can be seen in the FAQ.
The second new feature in V2.4 is related to IP address encodings. Sometimes it is necessary to encode, e.g. in OPTION_121, a network ID in a compact form. Example:
OPTION_121= 10.10.30.0/24 10.10.20.254 ; encodes to 18 0A 0A 1E 0A 0A 14 FE
This defines a classless static route for all addresses in the 10.10.30.0/24 network to be routed via 10.10.20.254. The encoding for this is an 8 byte octect sequence as shown above, where the first 4 octects are a compact CIDR syntax. Compact CIDR syntax means, that 10.10.30.0/24 only consists of the relevant octets for the network id. The relevant octets in this case are 3, because /24 makes the 4th octet of 10.10.30.0 irrelevant.
- Client sections with wildcards
A client section can be specified based on wildcards (since V1.7). Please use this with care. Recommendation is to not use client-id based specifications (UseClientID=0) and also to make sure that no interference with IPOOLs is possible, because the DHCP Server is not able to check this. This is how it works:
A client section can be defined based on wildcards like this:
What happens is that if a client that matches the above wildcard asks for an IP address, that the IP address assigned is automatically composed by using mac address byte 5 (%m5). The resulting mac address for client [00-01-02-03-04-6A] will be 192.168.17.106. (6A hex is 106 dec).
Mac address byte 0 through 5 are accessed accordingly with %m0 through %m5. The wildcard match algorithm searches in the following order and takes the first matching entry:
[00-01-02-03-04-6A] [00-01-02-03-04-??] [00-01-02-03-??-??] [00-01-02-??-??-??] [00-01-??-??-??-??] [00-??-??-??-??-??] [??-??-??-??-??-??]
In addition to the %m0 through %m5, since V2.3.1 there are further macros available. These are %ip0 through %ip3. They allow to access the IP address of the IPBIND_n address used by the current DHCP request. If IPBIND_1 is defined as IPBIND_1=192.168.5.1, then the macros are extended to: %ip0=192, %ip1=168, %ip2=5 and %ip3=1.
- $(section\name) syntax for INI file variables
Since version 2.0 of the DHCP Server the $(section\name) syntax can be used in the INI file. This helps to keep the INI file simple and prevents repeating information such as IP addresses in many places. Here is an example of a typical INI file:
[Settings] IPBIND_1=192.168.17.2 IPPOOL_1=192.168.17.2-50 AssociateBindsToPools=1 [DNS-Settings] EnableDNS=1 [General] SUBNETMASK=255.255.255.0 DNS_1=192.168.17.2
A clean and simple INI file with one IP pool and DNS enabled. If the IPBIND_1 interface ever changes, then one would need to change the IP address 192.168.17.2 in three places. No big deal but can be avoided with the following INI file utilizing the $(section\name) syntax:
[Settings] IPBIND_1=192.168.17.2 IPPOOL_1=$(Settings\IPBIND_1)-50 AssociateBindsToPools=1 [DNS-Settings] EnableDNS=1 [General] SUBNETMASK=255.255.255.0 DNS_1=$(IPBIND_1)
If the interface ever changes then only IPBIND_1 needs to be edited. $(IPBIND_1) is equivalent to $(Settings\IPBIND_1). Settings is sort of the default section. $(section\name) can be used for everything in the INI file. It can even be used for INI file entries that the DHCP Server doesn’t even know. Here is an example showing the usage for directories:
[Settings] BaseDir="d:\dhcpsrv" ; dhcpsrv.exe resides here IPBIND_1=192.168.17.2 IPPOOL_1=$(Settings\IPBIND_1)-50 AssociateBindsToPools=1 Trace=1 TraceFile="$(BaseDir)\dhcptrc.txt" ; trace file [DNS-Settings] EnableDNS=1 [General] SUBNETMASK=255.255.255.0 DNS_1=$(IPBIND_1) [TFTP-Settings] EnableTFTP=1 Root="$(BaseDir)\wwwroot" ; use wwwroot for http and tftp [HTTP-Settings] EnableHTTP=1 Root="$(BaseDir)\wwwroot" ; use wwwroot for http and tftp
This way the base dírectory of DHCP Server can be changed easily in one single place and the trace file and all the other entries that refer to files are always correct.