...
- option 1 - SUBNET_MASK,
- option 3 - GATEWAY_LIST,
- option 6 - TAG_DNS_LIST,
- option 33 - STATIC_ROUTE,
- option 42 - NTP_LIST,
- option 121 - CLASSLESS_ROUTE,
...
DHCP Options
DHCP client has the possibility to set up options that are sent to the DHCP server. For example, hostname and MAC address. The syntax is the same as for DHCP server options.
...
Name | code | value |
---|---|---|
clientid_duid | 61 | 0xff$(CLIENT_DUID) |
clientid | 61 | 0x01$(CLIENT_MAC) |
hostname | 12 | $(HOSTNAME) |
Properties
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 RouterOS client complies to RFC and ignores option 3 if classless option 121 is received. To force 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, 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: ) | Host name of the client sent to a DHCP server. If not specified, client's system identity will be used. |
interface (string; Default: ) | Interface on which 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) |
Read-only properties
Property | Description |
---|---|
address (IP/Netmask) | IP address and netmask, which is assigned to DHCP Client from the Server |
dhcp-server (IP) | IP address of the DHCP server. |
expires-after (time) | Time when the lease expires (specified by the DHCP server). |
gateway (IP) | IP address of the gateway which is assigned by DHCP server |
invalid (yes | no) | Shows whether configuration is invalid. |
netmask (IP) | |
primary-dns (IP) | IP address of the first DNS resolver, that was assigned by the DHCP server |
primary-ntp (IP) | IP address of the primary NTP server, assigned by the DHCP server |
secondary-dns (IP) | IP address of the second DNS resolver, assigned by the DHCP server |
secondary-ntp (IP) | IP address of the secondary NTP server, assigned by the DHCP server |
status (bound | error | rebinding... | requesting... | searching... | stopped) | Shows the status of DHCP Client |
Menu specific commands
Property | Description |
---|---|
release (numbers) | Release current binding and restart DHCP client |
renew (numbers) | Renew current leases. If the renew operation was not successful, client tries to reinitialize lease (i.e. it starts lease request procedure (rebind) as if it had not received an IP address yet) |
Configuration examples
Simple DHCP client
...
DHCP-client in RouterOS is capable of being a DHCPv6-client and DHCP-PD client. So it is able to get a prefix from DHCP-PD server as well as DHCPv6 stateful address from DHCPv6 server.
Properties
Property | Description |
---|---|
add-default-route (yes | no; Default: no) | Whether to add default IPv6 route after client connects. |
comment (string; Default: ) | Short description of the client |
disabled (yes | no; Default: no) | |
interface (string; Default: ) | Interface on which 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 the length of 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. |
Read-only properties
Property | Description |
---|---|
duid (string) | Auto generated DUID that is sent to the server. DUID is generated using one of the MAC addresses available on the router. |
request (list) | specifies what was requested - prefix, address or both. |
dynamic (yes | no) | |
expires-after (time) | Time when the IPv6 prefix expires (specified by the DHCPv6 server). |
invalid (yes | no) | Shows whether configuration is invalid. |
prefix (IPv6 prefix) | Shows received IPv6 prefix from DHCPv6-PD server |
status (stopped | searching | requesting... | bound | renewing | rebinding | error | stopping) | Shows the status of DHCPv6 Client:
|
Menu specific commands
Property | Description |
---|---|
release (numbers) | Release current binding and restart DHCPv6 client |
renew (numbers) | Renew current leases. If the renew operation was not successful, client tries to reinitialize lease (i.e. it starts lease request procedure (rebind) as if it had not received an IP address yet) |
Script
It is possible to add a script that will be executed when a prefix or an address is acquired and applied or expires and is removed using DHCP client. There are separated sets of variables that will have the value set by the client depending on prefix or address status change as the client can acquire both and each of them can have a different effect on the router configuration.
...
As DHCP replies can be unicast, the 'rogue DHCP detector' may not receive any offer to other DHCP clients at all. To deal with this, the rogue DHCP detector acts as a DHCP client as well - it sends out DHCP discover requests once a minute.
DHCP Options
Sub-menu: /ip dhcp-server option
...
Property | Description |
---|---|
code (integer:1..254; Default: ) | dhcp option code. All codes are available at http://www.iana.org/assignments/bootp-dhcp-parameters |
name (string; Default: ) | Descriptive name of the option |
value (string; Default: ) | Parameter's value. Available data types for options are:
RouterOS has predefined variables that can be used:
For example if HOSTNAME is 'kvm', then raw value will be 0x0176617264736b766d. |
raw-value (HEX string ) | Read-only field which shows raw DHCP option value (the format actually sent out) |
DHCP Option Sets
Sub-menu: /ip dhcp-server option sets
This menu allows combining multiple options in option sets, which later can be used to override the default DHCP server option set.
Example
Classless Route
A classless route adds a specified route in the clients routing table. In our example, it will add
...
Code Block | ||
---|---|---|
| ||
/ip dhcp-server option add code=252 name=auto-proxy-config value="'https://autoconfig.something.lv/wpad.dat'" |
DHCP Option Sets
Sub-menu: /ip dhcp-server option sets
...
Vendor Classes
Since 6.45beta6 version RouterOS support vendor class ID matcher. The vendor class is used by DHCP clients to optionally identify the vendor and configuration.
...
This sub-menu lists and allows to configure DHCP-PD servers.
Property | Description |
---|---|
address-pool (enum | static-only; Default: static-only) | IPv6 pool, from which to take IPv6 prefix for the clients. |
authoritative (after-10sec-delay | after-2sec-delay | yes | no; Default: after-2sec-delay) | Whether the DHCP server is the only DHCP server for the network:
|
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:
|
delay-threshold (time | none; Default: none) | If the secs 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) |
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
Code Block | ||
---|---|---|
| ||
[admin@RB493G] /ipv6 dhcp-server binding> print detail Flags: X - disabled, D - dynamic 0 D address=2a02:610:7501:ff00::/62 duid="1605fcb400241d1781f7" iaid=0 server=local-dhcp life-time=3d status=bound expires-after=2d23h40m10s last-seen=19m50s 1 D address=2a02:610:7501:ff04::/62 duid="0019d1393535" iaid=2 server=local-dhcp life-time=3d status=bound expires-after=2d23h43m47s last-seen=16m13s |
Menu specific commands
Property | Description |
---|---|
make-static () | Set dynamic binding as static. |
Rate limiting
It is possible to set the bandwidth to a specific IPv6 address by using DHCPv6 bindings. This can be done by setting a rate limit on the DHCPv6 binding itself, by doing this a dynamic simple queue rule will be added for the IPv6 address that corresponds to the DHCPv6 binding. By using the rate-limit
the parameter you can conveniently limit a user's bandwidth.
...
DHCP relay does not choose the particular DHCP server in the DHCP-server list, it just sends the incoming request to all the listed servers.
Properties
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 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 (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.
...