...
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 changewhen DHCP client obtains a new lease or loses an existing one. 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) |
...
Code Block | ||
---|---|---|
| ||
/ip dhcp-client print detail |
Anchor | ||||
---|---|---|---|---|
|
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-marktable=WAN1 and removes it when the lease expires or is removed.
Code Block | ||
---|---|---|
| ||
/ip dhcp-client add add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ether2 script="{\r\ \n :local rmark \"WAN1\"\r\ \n :local count [/ip route print count-only where comment=\"WAN1\"]\r\ \n :if (\$bound=1) do={\r\ \n :if (\$count = 0) do={\r\ \n /ip route add gateway=\$\"gateway-address\" comment=\"WAN1\" routing-marktable=\$rmark\r\ \n } else={\r\ \n :if (\$count = 1) do={\r\ \n :local test [/ip route find where comment=\"WAN1\"]\r\ \n :if ([/ip route get \$test gateway] != \$\"gateway-address\") do={\r\ \n /ip route set \$test gateway=\$\"gateway-address\"\r\ \n }\r\ \n } else={\r\ \n :error \"Multiple routes found\"\r\ \n }\r\ \n }\r\ \n } else={\r\ \n /ip route remove [find comment=\"WAN1\"]\r\ \n }\r\ \n}\r\ \n" |
...
Property | Description |
---|---|
add-default-route (yes | no; Default: no) | Whether to add default IPv6 route after a client connects. |
comment (string; Default: ) | Short description of the client |
disabled (yes | no; Default: no) | |
interface (string; Default: ) | The interface on which the DHCPv6 client will be running. |
pool-name (string; Default: ) | Name of the IPv6 pool in which received IPv6 prefix will be added |
pool-prefix-length (string; Default: ) | Prefix length parameter that will be set for IPv6 pool in which received IPv6 prefix is added. Prefix length must be greater than or equal as the length of the received prefix, otherwise, prefix-length will be set to received prefix length + 8 bits. |
prefix-hint (string; Default: ) | Include a preferred prefix length. |
request (prefix, address; Default: ) | to choose if the DHCPv6 request will ask for the address or the IPv6 prefix, or both. |
script (string; Default: ) | Run this script on the DHCP-client status change. Available variables:
|
use-peer-dns (yes | no; Default: yes) | Whether to accept the DNS settings advertised by the IPv6 DHCP Server. |
...
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) | Changes whether to force broadcast DHCP replies:
|
authoritative (after-10sec-delay | after-2sec-delay | |
yes | no; Default: |
yes) |
- yes - replies to clients request for an address that is not available from this server, DHCP server will send a negative acknowledgment (DHCPNAK);
- no - DHCP server ignores clients requests for addresses that are not available from this server;
- after-10sec-delay - requests with "secs < 10" will be processed as in "no" setting case and requests with "secs >= 10" will be processed as in "yes" case;
- after-2sec-delay - requests with "secs < 2" will be processed as in "no" setting case and requests with "secs >= 2" will be processed as in "yes" case;
- forever - lease never expires
- lease-time - use time from lease-time parameter
- none - do not respond to BOOTP requests
- static - offer only static leases to BOOTP clients
- dynamic - offer static and dynamic leases for BOOTP clients
- leaseBound - set to "1" if bound, otherwise set to "0"
- leaseServerName - DHCP server name
- leaseActMAC - active mac address
- leaseActIP - active IP address
- lease-hostname - client hostname
- lease-options - an array of received options
- 0.0.0.0 - the DHCP server will be used only for direct requests from clients (no DHCP relay allowed)
- 255.255.255.255 - the DHCP server should be used for any incoming request from a DHCP relay except for those, which are processed by another DHCP server that exists in the
/ip dhcp-server
submenu.
- no - do not use RADIUS;
- yes - use RADIUS for accounting and lease;
- accounting - use RADIUS for accounting only.
Store Configuration
Sub-menu: /ip dhcp-server config
This sub-menu allows the configuration of how often the DHCP leases will be stored on disk. If they would be saved on a disk on every lease change, a lot of disk writes would happen which is very bad for Compact Flash (especially, if lease times are very short). To minimize writes on disk, all changes are saved on disk every store-leases-disk seconds. Additionally, leases are always stored on disk on graceful shutdown and reboot.
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.
Note |
---|
For any queues to work properly, the traffic must not be FastTracked, make sure your Firewall does not FastTrack traffic that you want to limit. |
...
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. |
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: 30m) | 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) | Changes whether to force broadcast DHCP replies:
|
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
Store Leases On Disk: The configuration of how often the DHCP leases will be stored on disk. If they would be saved on a disk on every lease change, a lot of disk writes would happen which is very bad for Compact Flash (especially, if lease times are very short). To minimize writes on disk, all changes are saved on disk every store-leases-disk seconds. Additionally, leases are always stored on disk on graceful shutdown and reboot.
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.
Accounting: The accounting parameter in the DHCP server configuration enables or disables accounting for DHCP leases. When accounting is enabled, the DHCP server logs information about IP address assignments and lease renewals. This information can be useful for tracking and monitoring network usage, analyzing traffic patterns, or generating reports on IP address allocations.
Interim-update: The interim-update parameter determines whether the DHCP server sends periodic updates to the accounting server during a lease. These updates provide information about the lease duration, usage, and other relevant details. Enabling interim updates allows for more accurate tracking of lease activity.
Radius-password: The radius-password parameter is used to set the password for the RADIUS (Remote Authentication Dial-In User Service) server. RADIUS is a networking protocol commonly used for providing centralized authentication, authorization, and accounting for network access. When configuring the DHCP server to communicate with a RADIUS server for authentication or accounting purposes, you need to specify the correct password to establish a secure connection. This parameter ensures that the DHCP server can authenticate with the RADIUS server using the specified password.
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.
Note |
---|
For any queues to work properly, the traffic must not be FastTracked, make sure your Firewall does not FastTrack traffic that you want to limit. |
First, make the DHCPv4 lease static, otherwise, it will not be possible to set a rate limit to a DHCPv4 lease:
Code Block | ||
---|---|---|
| ||
[admin@MikroTik] > /ip dhcp-server lease print
Flags: X - disabled, R - radius, D - dynamic, B - blocked
# ADDRESS MAC-ADDRESS HOST-NAME SERVER RATE-LIMIT STATUS
0 D 192.168.88.254 6C:3B:6B:7C:41:3E MikroTik DHCPv4_Server bound
[admin@MikroTik] > /ip dhcp-server lease make-static 0
[admin@MikroTik] > /ip dhcp-server lease print
Flags: X - disabled, R - radius, D - dynamic, B - blocked
# ADDRESS MAC-ADDRESS HOST-NAME | ||
Code Block | ||
| ||
[admin@MikroTik] > /ip dhcp-server lease print Flags: X - disabled, R - radius, D - dynamic, B - blocked # ADDRESS MAC-ADDRESS HOST-NAME SERVER RATE-LIMIT STATUS 0 D 192.168.88.254 6C:3B:6B:7C:41:3E MikroTik DHCPv4_Server bound [admin@MikroTik] > /ip dhcp-server lease make-static 0 [admin@MikroTik] > /ip dhcp-server lease print Flags: X - disabled, R - radius, D - dynamic, B - blocked # ADDRESS MAC-ADDRESS HOST-NAME SERVER RATE-LIMIT STATUS 0 192.168.88.254 6C:3B:6B:7C:41:3E MikroTik DHCPv4_Server bound |
...
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" |
...
Code Block | ||
---|---|---|
| ||
/ip dhcp-server network add address=192.168.88.0/24 dns-server=192.168.88.1 gateway=192.168.88.1 |
- In our case, the device itself is serving as the gateway, so we'll add the address to the bridge interface:
Code Block | ||
---|---|---|
| ||
/ip address add address=192.168.88.1/24 interface=bridge1 network=192.168.88.0 |
- And finally, add DHCP Server, here we will add the previously created address pool, and specify on which interface the DHCP server should work on
Code Block | ||
---|---|---|
| ||
/ip dhcp-server add address-pool=dhcp_pool0 disabled=no interface=bridge1 name=dhcp1 |
DHCPv6 Server
Summary
Standards: RFC 3315, RFC 3633
Single DUID is used for client and server identification, only IAID will vary between clients corresponding to their assigned interface.
Client binding creates a dynamic pool with a timeout set to binding's expiration time (note that now dynamic pools can have a timeout), which will be updated every time binding gets renewed.
When a client is bound to a prefix, the DHCP server adds routing information to know how to reach the assigned prefix.
Client bindings in the server do not show MAC address anymore (as it was in v5.8), DUID (hex) and IAID are used instead. After upgrade, MAC addresses will be converted to DUIDs automatically, but due to unknown DUID type and unknown IAID, they should be further updated by the user;
Note |
---|
RouterOS DHCPv6 server can only delegate IPv6 prefixes, not addresses. |
General
Sub-menu: /ipv6 dhcp-server
This sub-menu lists and allows to configure DHCP-PD servers.
/24 dns-server=192.168.88.1 gateway=192.168.88.1 |
- In our case, the device itself is serving as the gateway, so we'll add the address to the bridge interface:
Code Block | ||
---|---|---|
| ||
/ip address add address=192.168.88.1/24 interface=bridge1 network=192.168.88.0 |
- And finally, add DHCP Server, here we will add the previously created address pool, and specify on which interface the DHCP server should work on
Code Block | ||
---|---|---|
| ||
/ip dhcp-server add address-pool=dhcp_pool0 disabled=no interface=bridge1 name=dhcp1 |
DHCPv6 Server
Summary
Standards: RFC 3315, RFC 3633
Single DUID is used for client and server identification, only IAID will vary between clients corresponding to their assigned interface.
Client binding creates a dynamic pool with a timeout set to binding's expiration time (note that now dynamic pools can have a timeout), which will be updated every time binding gets renewed.
When a client is bound to a prefix, the DHCP server adds routing information to know how to reach the assigned prefix.
Client bindings in the server do not show MAC address anymore (as it was in v5.8), DUID (hex) and IAID are used instead. After upgrade, MAC addresses will be converted to DUIDs automatically, but due to unknown DUID type and unknown IAID, they should be further updated by the user;
Note |
---|
RouterOS DHCPv6 server can only delegate IPv6 prefixes, not addresses. |
General
Sub-menu: /ipv6 dhcp-server
This sub-menu lists and allows to configure DHCP-PD servers.
DHCPv6 Server Properties
Property | Description |
---|---|
address-pool (enum | static-only; Default: static-only) | IPv6 pool, from which to take IPv6 prefix for the clients. |
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. |
binding-script (string; Default: ) | A script that will be executed after binding is assigned or de-assigned. Internal "global" variables that can be used in the script:
|
dhcp- |
option ( |
string; Default: none) |
Add additional DHCP options from option list. | |
disabled (yes | no; Default: no) | Whether DHCP-PD server participates in the prefix assignment process. |
interface (string; Default: ) | The interface on which server will be running. |
lease-time (time; Default: 3d) | 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 |
Read-only Properties
Property | Description |
---|---|
dynamic (yes | no) | |
invalid (yes | no) |
Bindings
Sub-menu: /ipv6 dhcp-server binding
DUID is used only for dynamic bindings, so if it changes then the client will receive a different prefix than previously.
Property | Description |
---|---|
address (IPv6 prefix; Default: ) | IPv6 prefix that will be assigned to the client |
allow-dual-stack-queue (yes | no; Default: yes) | Creates a single simple queue entry for both IPv4 and IPv6 addresses, uses the MAC address and DUID for identification. Requires IPv4 DHCP Server to have this option enabled as well to work properly. |
comment (string; Default: ) | Short description of an item. |
disabled (yes | no; Default: no) | Whether an item is disabled |
dhcp-option (string; Default: ) | Add additional DHCP options from the option list. |
dhcp-option-set (string; Default: ) | Add an additional set of DHCP options. |
life-time (time; Default: 3d) | The time period after which binding expires. |
duid (hex string; Default: ) | DUID value. Should be specified only in hexadecimal format. |
iaid (integer [0..4294967295]; Default: ) | Identity Association Identifier, part of the Client ID. |
prefix-pool (string; Default: ) | Prefix pool that is being advertised to the DHCPv6 Client. |
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. |
server (string | all; Default: all) | Name of the server. If set to all, then binding applies to all created DHCP-PD servers. |
Read-only properties
Property | Description |
---|---|
dynamic (yes | no) | Whether an item is dynamically created. |
expires-after (time) | The time period after which binding expires. |
last-seen (time) | Time period since the client was last seen. |
status (waiting | offered | bound) | Three status values are possible:
|
For example, dynamically assigned /62 prefix
...
Property | Description |
---|---|
add-relay-info (yes | no; Default: no) | Adds DHCP relay agent information if enabled according to RFC 3046. Agent Circuit ID Sub-option contains mac address of an interface, Agent Remote ID Sub-option contains MAC address of the client from which request was received. |
delay-threshold (time | none; Default: none) | If secs field in DHCP packet is smaller than delay-threshold, then this packet is ignored |
dhcp-server (string; Default: ) | List of DHCP servers' IP addresses which should the DHCP requests be forwarded toDHCP requests be forwarded to |
interface (string; Default: ) | Interface name the DHCP relay will be working on. |
local-address (IP; Default: 0.0.0.0) | The unique IP address of this DHCP relay needed for DHCP server to distinguish relays. If set to 0.0.0.0 - the IP address will be chosen automatically |
relay-info-remote-id (string; Default: ) | specified string will be used to construct Option 82 instead of client's MAC address. Option 82 consist of: interface from which packets was received + client mac address or relay-info-remote-id |
name interface (string; Default: ) | Interface Descriptive name for the DHCP relay will be working on. |
local-address (IP; Default: 0.0.0.0) | The unique IP address of this DHCP relay needed for DHCP server to distinguish relays. If set to 0.0.0.0 - the IP address will be chosen automatically |
relay-info-remote-id (string; Default: ) | specified string will be used to construct Option 82 instead of client's MAC address. Option 82 consist of: interface from which packets was received + client mac address or relay-info-remote-id |
name (string; Default: ) | Descriptive name for the relay |
Configuration Example
Let us consider that you have several IP networks 'behind' other routers, but you want to keep all DHCP servers on a single router. To do this, you need a DHCP relay on your network which will relay DHCP requests from clients to the DHCP server.
This example will show you how to configure a DHCP server and a DHCP relay that serves 2 IP networks - 192.168.1.0/24 and 192.168.2.0/24 that are behind a router DHCP-Relay.
IP Address Configuration
relay |
Configuration Example
Let us consider that you have several IP networks 'behind' other routers, but you want to keep all DHCP servers on a single router. To do this, you need a DHCP relay on your network which will relay DHCP requests from clients to the DHCP server.
This example will show you how to configure a DHCP server and a DHCP relay that serves 2 IP networks - 192.168.1.0/24 and 192.168.2.0/24 that are behind a router DHCP-Relay.
IP Address Configuration
IP addresses of DHCP-Server:
Code Block | ||
---|---|---|
| ||
[admin@DHCP-Server] ip address> print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 192.168.0.1/24 192.168.0.0 192.168.0.255 To-DHCP-Relay
1 10.1.0.2/24 10.1.0.0 10.1.0.255 Public
[admin@DHCP-Server] ip address> |
IP addresses of DHCP-RelayIP addresses of DHCP-Server:
Code Block | ||
---|---|---|
| ||
[admin@DHCP-ServerRelay] ip address> print Flags: X - disabled, I - invalid, D - dynamic # ADDRESS NETWORK BROADCAST INTERFACE 0 0 192.168.0.2/24 192.168.0.0 192.168.0.255 To-DHCP-Server 1 192.168.1.1/24 192.168.1.0 192.168.1.255 Local1 2 192.168.02.1/24 192.168.02.0 192.168.02.255 To-DHCP-Relay 1 10Local2 [admin@DHCP-Relay] ip address> |
DHCP Server Setup
To setup 2 DHCP Servers on the DHCP-Server router add 2 pools. For networks 192.168.1.0/24 and 192.168.2.0:
Code Block | ||
---|---|---|
| ||
/ip pool add name=Local1-Pool ranges=192.168/24 10.1.0.0 1011-192.168.1.0.255 Public [admin@DHCP-Server] ip address> |
IP addresses of DHCP-Relay:
Code Block | ||
---|---|---|
| ||
[admin@DHCP-Relay100 /ip pool add name=Local2-Pool ranges=192.168.2.11-192.168.2.100 [admin@DHCP-Server] ip address>pool> print Flags: X - disabled, I - invalid, D - dynamic # # NAME ADDRESS NETWORK BROADCAST INTERFACERANGES 0 Local1-Pool 192.168.0.2/24 192.168.0.0 192.168.0.255 To-DHCP-Server 1 192.168.1.1/2411-192.168.1.100 1 Local2-Pool 192.168.1.0 192.168.1.255 Local1 2 192.168.2.1/24 192.168.2.0 11-192.168.2.255 Local2100 [admin@DHCP-RelayServer] ip address>pool> |
Create DHCP Server SetupTo setup 2 DHCP Servers on the DHCP-Server router add 2 pools. For networks 192.168.1.0/24 and 192.168.2.0:
Code Block | ||
---|---|---|
| ||
/ip pooldhcp-server add nameinterface=Local1To-DHCP-PoolRelay rangesrelay=192.168.1.11-192.168.1.1001 \ address-pool=Local1-Pool name=DHCP-1 disabled=no /ip pooldhcp-server add nameinterface=Local1To-DHCP-PoolRelay rangesrelay=192.168.2.11-192.168.2.1001 \ address-pool=Local2-Pool name=DHCP-2 disabled=no [admin@DHCP-Server] ip pool>dhcp-server> print Flags: #X NAME- disabled, I - invalid # NAME INTERFACE RELAY ADDRESS-POOL RANGESLEASE-TIME ADD-ARP 0 Local1-Pool DHCP-1 To-DHCP-Relay 192.168.1.11-192.168.1.100 1 Local2-Pool Local1-Pool 3d00:00:00 1 DHCP-2 To-DHCP-Relay 192.168.2.1 192.168.2.11-192.168.2.100Local2-Pool 3d00:00:00 [admin@DHCP-Server] ip pool>dhcp-server> |
Configure respective networksCreate DHCP Servers:
Code Block | ||
---|---|---|
| ||
/ip dhcp-server network add interface=To-DHCP-Relay relayaddress=192.168.1.0/24 gateway=192.168.1.1 \ addressdns-pool=Local1-Pool name=DHCP-1 disabled=noserver=159.148.60.20 /ip dhcp-server network add interface=To-DHCP-Relay relayaddress=192.168.2.0/24 gateway=192.168.2.1 \ address-pool=Local2-Pool name=DHCP-2 disabled=nodns-server 159.148.60.20 [admin@DHCP-Server] ip dhcp-server>server network> print Flags: X - disabled, I - invalid # ADDRESS NAME INTERFACE GATEWAY RELAY DNS-SERVER ADDRESS-POOL LEASE-TIME ADD-ARP 0 WINS-SERVER DHCP-1 DOMAIN 0 192.168.1.0/24 To-DHCP-Relay 192.168.1.1 Local1-Pool 3d00:00:00159.148.60.20 1 DHCP-2192.168.2.0/24 To-DHCP-Relay 192.168.2.1 Local2-Pool 3d00:00:00159.148.60.20 [admin@DHCP-Server] ip dhcp-server>server network> |
DHCP Relay Config
Configuration of DHCP-Server is done. Now let's configure DHCP-RelayConfigure respective networks:
Code Block | ||
---|---|---|
| ||
/ip dhcp-server network add addressrelay add name=Local1-Relay interface=Local1 \ dhcp-server=192.168.1.0/24 gateway0.1 local-address=192.168.1.1 \disabled=no /ip dhcp-relay add dns-server=159.148.60.20 /ipname=Local2-Relay interface=Local2 \ dhcp-server network add address=192.168.20.0/24 gateway1 local-address=192.168.2.1 \ dns-server 159.148.60.20 disabled=no [admin@DHCP-ServerRelay] ip dhcp-server network> print-relay> print Flags: X - disabled, I - invalid # ADDRESS NAME INTERFACE GATEWAY DHCP-SERVER LOCAL-ADDRESS 0 DNS-SERVERLocal1-Relay Local1 WINS-SERVER DOMAIN 0 192.168.0.1.0/24 192.168.1.1 1 Local2-Relay Local2 159.148.60.20 1 192.168.20.0/241 192.168.2.1 [admin@DHCP-Relay] ip dhcp-relay> |
DHCP Relay with VRF (introduced in 7.15)
Let's take the previous setup but we'll consider that the interface to the DHCP server and interfaces to DHCP clients are added in VRF:
Code Block | ||
---|---|---|
| ||
/ip vrf add 159.148.60.20 [admin@DHCP-Server] ip dhcp-server network> |
DHCP Relay Config
...
interfaces=To-DHCP-Server name=vrf_server
add interfaces=Local2 name=vrf2
add interfaces=Local1 name=vrf1 |
In the DHCP-relay configuration dhcp-server-vrf should be added:
Code Block | ||
---|---|---|
| ||
/ip dhcp-relay add name=Local1-Relay interface=Local1 \ dhcp-server=192.168.0.1 local/set dhcp-server-vrf=vrf_server numbers=0,1 |
Due to VRF configuration there are several routing-tables - we should add additional routes:
Code Block | ||
---|---|---|
| ||
/ip route add disabled=no distance=1 dst-address=192.168.10.10/24 disabled=no /ip dhcp-relay add name=Local2-Relay interface=Local2 \ dhcp-server=192.168.0.1 localgateway=To-DHCP-Server@vrf_server pref-src="" routing-table=vrf1 scope=10 suppress-hw-offload=no \ target-scope=10 add disabled=no distance=1 dst-address=192.168.20.10/24 disabled=no [admin@DHCP-Relay] ip dhcp-relay> print Flags: X - disabled, I - invalid # NAME INTERFACE DHCP-SERVER LOCAL-ADDRESS 0 Local1-Relay Local1 gateway=To-DHCP-Server@vrf_server pref-src="" routing-table=vrf2 scope=10 suppress-hw-offload=no \ target-scope=10 add disabled=no dst-address=192.168.1.0/24 gateway=Local1@vrf1 routing-table=vrf_server suppress-hw-offload=no add disabled=no distance=1 dst-address=192.168.2.0/24 gateway=Local2@vrf2 pref-src="" routing-table=vrf_server scope=30 suppress-hw-offload=no \ target-scope=10 |
To achieve successful DHCP-server - DHCP-relay communication we should add NAT rules:
Code Block | ||
---|---|---|
| ||
/ip firewall nat add action=dst-nat chain=dstnat dst-address=192.168.2.1 dst-port=67 in-interface=To-DHCP-Server protocol=udp src-address=192.168.0.1 to-addresses=\ 192.168.10.12 add 1 Local2-Relay Local2 action=dst-nat chain=dstnat dst-address=192.168.1.1 dst-port=67 in-interface=To-DHCP-Server protocol=udp src-address=192.168.0.1 to-addresses=\ 192.168.2.1 [admin@DHCP-Relay] ip dhcp-relay>0.2 |