...
The MikroTik RouterOS DHCP client may be enabled on any Ethernet-like interface at a time. The client will accept an address, netmask, default gateway, and two DNS server addresses. The received IP address will be added to the interface with the respective netmask. The default gateway will be added to the routing table as a dynamic entry. Should the DHCP client be disabled or not renew an address, the dynamic default route will be removed. If there is already a default route installed prior to the DHCP client obtaining one, the route obtained by the DHCP client would be shown as invalid.address-pool
RouterOS DHCP client asks for the following options:
...
Property | Description |
---|---|
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+
|
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:
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) |
...
Property | Description |
---|---|
address (IP/Netmask) | IP address and netmask, which is assigned to DHCP Client from the Server |
dhcp-server (IP) | The IP address of the DHCP server. |
expires-after (time) | A time when the lease expires (specified by the DHCP server). |
gateway (IP) | The IP address of the gateway which is assigned by the DHCP server |
invalid (yes | no) | Shows whether a configuration is invalid. |
netmask (IP) | |
primary-dns (IP) | The IP address of the first DNS resolver, that which was assigned by the DHCP server |
primary-ntp (IP) | The IP address of the primary NTP server, assigned by the DHCP server |
secondary-dns (IP) | The IP address of the second DNS resolver, assigned by the DHCP server |
secondary-ntp (IP) | The IP address of the secondary NTP server, assigned by the DHCP server |
status (bound | error | rebinding... | requesting... | searching... | stopped) | Shows the status of the DHCP Client |
Menu specific commands
Property | Description |
---|---|
release (numbers) | Release current binding and restart the DHCP client |
renew (numbers) | Renew current leases. If the renewal operation was not successful, the client tries to reinitialize the lease (i.e. it starts the lease request procedure (rebind) as if it had not received an IP address yet) |
...
Note |
---|
DHCP server requires a real interface to receive raw ethernet packets. If the interface is a Bridge interface, then the Bridge must have a real interface attached as a port to that bridge which will receive the raw ethernet packets. It cannot function correctly on a dummy (empty bridge) interface. |
Leases
Sub-menu: /ip dhcp-server lease
DHCP server lease submenu is used to monitor and manage server leases. The issued leases are shown here as dynamic entries. You can also add static leases to issue a specific IP address to a particular client (identified by MAC address).
Generally, the DHCP lease is allocated as follows:
- an unused lease is in the "waiting" state
- if a client asks for an IP address, the server chooses one
- if the client receives a statically assigned address, the lease becomes offered, and then bound with the respective lease time
- if the client receives a dynamic address (taken from an IP address pool), the router sends a ping packet and waits for an answer for 0.5 seconds. During this time, the lease is marked testing
- in the case where the address does not respond, the lease becomes offered and then bound with the respective lease time
- in other cases, the lease becomes busy for the lease time (there is a command to retest all busy addresses), and the client's request remains unanswered (the client will try again shortly)
A client may free the leased address. The dynamic lease is removed, and the allocated address is returned to the address pool. But the static lease becomes busy until the client reacquires the address.
Note |
---|
IP addresses assigned statically are not probed! |
Properties
DHCP Server Properties
Property | Description |
---|---|
add-arp (yes | no; Default: no) | Whether to add dynamic ARP entry. If set to no either ARP mode should be enabled on that interface or static ARP entries should be administratively defined in /ip arp submenu. |
address-pool (string | static-only; Default: static-only) | IP pool, from which to take IP addresses for the clients. If set to static-only, then only the clients that have a static lease (added in the lease submenu) will be allowed. |
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) | Always send replies as broadcasts even if the destination IP is known. Will add additional load on L2 network. |
authoritative (after-10sec-delay | after-2sec-delay | yes | no; Default: yes) | Option changes the way how a server responds to DHCP requests:
|
bootp-lease-time (forever | lease-time | time; Default: forever) | Accepts two predefined options or time value:
|
bootp-support (none | static | dynamic; Default: static) | Support for BOOTP clients:
|
client-mac-limit (integer | unlimited; Default: unlimited) | Specifies whether to limit a specific number of clients per single MAC address or leave unlimited. Note that this setting should not be used in relay setups. |
conflict-detection (yes | no; Default: yes) | Allows disabling/enabling conflict detection. If the option is enabled, then whenever the server tries to assign a lease it will send ICMP and ARP messages to detect whether such an address in the network already exists. If any of the above get a reply address is considered already used. Conflict detection must be disabled when any kind of DHCP client limitation per port or per mac is used. |
delay-threshold (time | none; Default: none) | If the sec's field in the DHCP packet is smaller than the delay threshold, then this packet is ignored. If set to none - there is no threshold (all DHCP packets are processed) |
dhcp-option-set (name | none; Default: none) | Use a custom set of DHCP options defined in the option sets menu. |
insert-queue-before (bottom | first | name; Default: first) | Specify where to place dynamic simple queue entries for static DCHP leases with a rate-limit parameter set. |
interface (string; Default: ) | The interface on which the DHCP server will be running. |
lease-script (string; Default: "") | A script that will be executed after a lease is assigned or de-assigned. Internal "global" variables that can be used in the script:
|
lease-time (time; Default: 10m) | The time that a client may use the assigned address. The client will try to renew this address after half of this time and will request a new address after the time limit expires. |
name (string; Default: ) | Reference name |
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. |
relay (IP; Default: 0.0.0.0) | The IP address of the relay this DHCP server should process requests from:
|
server-address (IP; Default: 0.0.0.0) | The IP address of the server to use in the next step of the client's bootstrap process (For example, to assign a specific server address in case several addresses are assigned to the interface) |
use-framed-as-classless |
(yes | no; Default: yes) |
Forward RADIUS Framed-Route as a DHCP Classless-Static-Route to DHCP-client. Whenever both Framed-Route and Classless-Static-Route are received Classless-Static-Route is preferred. |
use-radius |
(yes | no | accounting; Default: no) | Whether to use RADIUS server:
|
Leases
Sub-menu: /ip dhcp-server lease
DHCP server lease submenu is used to monitor and manage server leases. The issued leases are shown here as dynamic entries. You can also add static leases to issue a specific IP address to a particular client (identified by MAC address).
Generally, the DHCP lease is allocated as follows:
- an unused lease is in the "waiting" state
- if a client asks for an IP address, the server chooses one
- if the client receives a statically assigned address, the lease becomes offered, and then bound with the respective lease time
- if the client receives a dynamic address (taken from an IP address pool), the router sends a ping packet and waits for an answer for 0.5 seconds. During this time, the lease is marked testing
- in the case where the address does not respond, the lease becomes offered and then bound with the respective lease time
- in other cases, the lease becomes busy for the lease time (there is a command to retest all busy addresses), and the client's request remains unanswered (the client will try again shortly)
A client may free the leased address. The dynamic lease is removed, and the allocated address is returned to the address pool. But the static lease becomes busy until the client reacquires the address.
Note |
---|
IP addresses assigned statically are not probed! |
Property | Description | ||
---|---|---|---|
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. | Always send replies as broadcasts even if the destination IP is known. Will add additional load on L2 network. | authoritative (after-10sec-delay | after-2sec-delay | yes | no; Default: yes) | Option changes the way how a server responds to DHCP requests:
bootp-lease-time (forever | lease-time | time; Default: ) | Accepts two predefined options or time value:
| ||
bootp-support (none | static | dynamic; Default: static) | Support for BOOTP clients:
| ||
client-mac-limit (integer | unlimited; Default: unlimited) | Specifies whether to limit a specific number of clients per single MAC address or leave unlimited. Note that this setting should not be used in relay setups. | ||
conflict-detection (yes | no; Default: ) | Allows disabling/enable conflict detection. If the option is enabled, then whenever the server tries to assign a lease it will send ICMP and ARP messages to detect whether such address in the network already exists. If any of the above get reply address is considered already used. Conflict detection must be disabled when any kind of DHCP client limitation per port or per mac is used. | ||
delay-threshold (time | none; Default: none) | If the sec's field in the DHCP packet is smaller than the delay threshold, then this packet is ignored. If set to none - there is no threshold (all DHCP packets are processed) | ||
dhcp-option-set (name | none; Default: ) | Use a custom set of DHCP options defined in the option sets menu. | ||
insert-queue-before (bottom | first | name; Default: ) | Specify where to place dynamic simple queue entries for static DCHP leases with a rate-limit parameter set. | ||
interface (string; Default: ) | The interface on which server will be running. | ||
lease-script (string; Default: "") | A script that will be executed after a lease is assigned or de-assigned. Internal "global" variables that can be used in the script: | ||
lease-time (time; Default: 10m0s) | The time Time that a the client may use the assigned address. The client will try to renew this address after half of this time and will request a new address after the time limit expires.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 | name (string; Default: ) | Reference name |
parent-queue (string | none; Default: none) | |||
relay (IP; Default: 0.0.0.0) | The IP address of the relay this DHCP server should process requests from:
| ||
src-address (IP; Default: 0.0.0.0) | The address to which the DHCP client must send requests in order to renew an IP address lease. If there is only one static address on the DHCP server interface and the source address is left as 0.0.0.0, then the static address will be used. If there are multiple addresses on the interface, an address in the same subnet as the range of given addresses should be used. | ||
use-framed-as-classless (yes | no; Default: yes) | Forward RADIUS Framed-Route as a DHCP Classless-Static-Route to DHCP-client. Whenever both Framed-Route and Classless-Static-Route are received Classless-Static-Route is preferred. | ||
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 | use-radius (yes | no | accounting; Default: no) | Whether to use RADIUS server: |
Store Configuration
Sub-menu: /ip dhcp-server config
...
Note |
---|
The DHCP alert is not recommended on devices that are configured as DHCP clients. Since the alert itself generates DHCP discovery packets, it can affect the operation of the DHCP client itself. Use this feature only on devices that are DHCP servers or using a static IP address. |
Sub-menu: /ip dhcp-server alert
Properties
Property | Description |
---|---|
alert-timeout (none | time; Default: 1h) | Time after which the alert will be forgotten. If after that time the same server is detected, a new alert will be generated. If set to none timeout will never expire. |
interface (string; Default: ) | Interface, on which to run rogue DHCP server finder. |
on-alert (string; Default: ) | Script to run, when an unknown DHCP server is detected. |
valid-server (string; Default: ) | List of MAC addresses of valid DHCP servers. |
Read-only properties
Property | Description |
---|---|
unknown-server (string) | List of MAC addresses of detected unknown DHCP servers. The server is removed from this list after alert-timeout |
Menu specific commands
Property | Description |
---|---|
reset-alert (id) | Clear all alerts on an interface |
DHCP Options
Sub-menu: /ip dhcp-server option
...
Match the code 12 using the string:
Code Block | ||
---|---|---|
| ||
/ip dhcp-server matcher
add address-pool=testpool code=12 name=test server=dhcp1 value="MikroTik" |
...