Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

PropertyDescription
add-default-route (yes | no | special-classless; Default: yes)Whether to install default route in routing table received from DHCP server. By default, the RouterOS client complies with RFC and ignores option 3 if classless option 121 is received. To force the client not to ignore option 3 set special-classless. This parameter is available in v6rc12+
  • yes - adds classless route if received, if not then add default route (old behavior)
  • special-classless - adds both classless routes if received and a default route (MS style)
client-id (string; Default: )Corresponds to the settings suggested by the network administrator or ISP. If not specified, the client's MAC address will be sent
comment (string; Default: )Short description of the client
default-route-distance (integer:0..255; Default: )Distance of default route. Applicable if add-default-route is set to yes.
disabled (yes | no; Default: yes)
host-name (string; Default: )The hostname of the client is sent to a DHCP server. If not specified, the client's system identity will be used.
interface (string; Default: )The interface on which the DHCP client will be running.
script (script; Default: )Execute script on status change. This parameter is available in v6.39rc33+ These are available variables that are accessible for the event script:
  • bound - 1 - lease is added/changed; 0 - lease is removed
  • server-address - server address
  • lease-address - lease address provided by a server
  • interface - name of the interface on which the client is configured
  • gateway-address - gateway address provided by a server
  • vendor-specific - stores value of option 43 received from DHCP server
  • lease-options - an array of received options
Example >>
use-peer-dns (yes | no; Default: yes)Whether to accept the DNS settings advertised by DHCP Server. (Will override the settings put in the /ip dns submenu.
use-peer-ntp (yes | no; Default: yes)Whether to accept the NTP settings advertised by DHCP Server. (Will override the settings put in the /system ntp client submenu)

...

Code Block
languageros
/ip dhcp-client print detail 

Anchor
LeaseScriptExample
LeaseScriptExample
Lease script example

It is possible to execute a script when a DHCP client obtains a new lease or loses an existing one. This is an example script that automatically adds a default route with routing-mark=WAN1 and removes it when the lease expires or is removed.

...

PropertyDescription
address (IP; Default: 0.0.0.0)Specify IP address (or ip pool) for static lease. If set to 0.0.0.0 - a pool from the DHCP server will be used
address-list (string; Default: none)Address list to which address will be added if the lease is bound.
allow-dual-stack-queue (yes | no; Default: yes)Creates a single simple queue entry for both IPv4 and IPv6 addresses, and uses the MAC address and DUID for identification. Requires IPv6 DHCP Server to have this option enabled as well to work properly.
always-broadcast (yes | no; Default: no)Send all replies as broadcasts
block-access (yes | no; Default: no)Block access for this client
client-id (string; Default: none)If specified, must match the DHCP 'client identifier' option of the request
dhcp-option (string; Default: none)Add additional DHCP options from option list.
dhcp-option-set (string; Default: none)Add an additional set of DHCP options.
insert-queue-before (bottom | first | name; Default: first)Specify where to place dynamic simple queue entries for static DCHP leases with rate-limit parameter set.
lease-time (time; Default: 0s)Time that the client may use the address. If set to 0s lease will never expire.
mac-address (MAC; Default: 00:00:00:00:00:00)If specified, must match the MAC address of the client
parent-queue (string | none; Default: none)A dynamically created queue for this lease will be configured as a child queue of the specified parent queue.
queue-type (default, ethernet-default, multi-queue-ethernet-default, pcq-download-default, synchronous-default, default-small, hotspot-default, only-hardware-queue, pcq-upload-default, wireless-default)Queue type that can be assigned to the specific lease
rate-limit (integer[/integer] [integer[/integer] [integer[/integer] [integer[/integer]]]];; Default: )Adds a dynamic simple queue to limit IP's bandwidth to a specified rate. Requires the lease to be static. Format is: rx-rate[/tx-rate] [rx-burst-rate[/tx-burst-rate] [rx-burst-threshold[/tx-burst-threshold] [rx-burst-time[/tx-burst-time]]]]. All rates should be numbers with optional 'k' (1,000s) or 'M' (1,000,000s). If tx-rate is not specified, rx-rate is as tx-rate too. Same goes for tx-burst-rate and tx-burst-threshold and tx-burst-time. If both rx-burst-threshold and tx-burst-threshold are not specified (but burst-rate is specified), rx-rate and tx-rate is used as burst thresholds. If both rx-burst-time and tx-burst-time are not specified, 1s is used as default.
routes ([dst-address/mask] [gateway] [distance]; Default: none)

Routes that appear on the server when the client is connected. It is possible to specify multiple routes separated by commas. This setting will be ignored for OpenVPN.

server (string)Server name which serves this client
use-src-mac (yes | no; Default: no)When this option is set server uses the source MAC address instead of the received CHADDR to assign the address.

Menu specific commands

check-status (id)Check the status of a given busy (status is conflict or declined) dynamic lease, and free it in case of no response
make-static (id)Convert a dynamic lease to a static one

Store Configuration

Sub-menu: /ip dhcp-server config

...

Manual changes to leases - addition/removal of a static lease, removal of a dynamic lease will cause changes to be pushed for this lease to storage.

Rate limiting

It is possible to set the bandwidth to a specific IPv4 address by using DHCPv4 leases. This can be done by setting a rate limit on the DHCPv4 lease itself, by doing this a dynamic simple queue rule will be added for the IPv4 address that corresponds to the DHCPv4 lease. By using the rate-limit parameter you can conveniently limit a user's bandwidth.

...