...
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) |
...
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. |
...
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) | 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 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:
|
...
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 ( | 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. |
...
Sub-menu: /ip dhcp-server config
This sub-menu allows the 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.
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. |
...
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 | ||
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 |
...
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 |
...
- You can make binding to specific client static so that it always receives the same prefix:
Code Block | ||
---|---|---|
| ||
[admin@RB493G] /ipv6 dhcp-server binding> print Flags: X - disabled, D - dynamic # ADDRESS DU IAID SER.. STATUS 0 D 2001:db8:7501:1::/62 16 0 loc.. bound [admin@RB493G] /ipv6 dhcp-server binding> print -server binding> make-static 0 |
- DHCP-PD also installs a route to assigned prefix into IPv6 routing table:
Code Block | ||
---|---|---|
| ||
[admin@RB493G] /ipv6 route> print Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, o - ospf, b - bgp, U - unreachable # DST-ADDRESS DUGATEWAY IAIDDISTANCE SER ... STATUS 0 D 2 ADS 2001:db8:7501:1::/62 16 0 loc.. bound [admin@RB493G] /ipv6 dhcp-server binding> make-static 0 |
- DHCP-PD also installs a route to assigned prefix into IPv6 routing table:
Code Block | ||
---|---|---|
| ||
[admin@RB493G] /ipv6 route> print
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, o - ospf, b - bgp, U - unreachable
# DST-ADDRESS GATEWAY DISTANCE
...
2 ADS 2001:db8:7501:1::/62 fe80::224:1dff:fe17:8... 1 |
DHCP Relay
Summary
Sub-menu: /ip dhcp-relay
The purpose of the DHCP relay is to act as a proxy between DHCP clients and the DHCP server. It is useful in networks where the DHCP server is not on the same broadcast domain as the DHCP client.
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.
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
fe80::224:1dff:fe17:8... 1 |
DHCP Relay
Summary
Sub-menu: /ip dhcp-relay
The purpose of the DHCP relay is to act as a proxy between DHCP clients and the DHCP server. It is useful in networks where the DHCP server is not on the same broadcast domain as the DHCP client.
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.
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 192.168.0.2/24 192.168.0.0 192.168.0.255 To-DHCP-Server 1 BROADCAST192.168.1.1/24 192.168.1.0 192.168.1.255 INTERFACELocal1 02 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 192.168.0.2/24Local1-Pool 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 ADDWINS-ARP SERVER 0 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-2 192.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 address-relay add name=Local1-Relay interface=Local1 \ dhcp-server=192.168.0.1.0/24 gateway 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.20disabled=no [admin@DHCP-ServerRelay] ip dhcp-server network> print # ADDRESS-relay> print Flags: X - disabled, I - invalid # NAME INTERFACE DHCP-SERVER LOCAL-ADDRESS 0 Local1-Relay GATEWAY DNS-SERVER Local1 WINS-SERVER DOMAIN 0 192.168.0.1.0/24 192.168.1.1 1 Local2-Relay 159.148.60.20 1 192.168.2.0/24 Local2 192.168.20.1 159192.148168.602.201 [admin@DHCP-Server] ip dhcp-server network> |
DHCP Relay Config
...
-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 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 192.168.0.1 192.168.1.1 1 Local2-Relay Local2 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.0.2 add 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 |