Difference between revisions of "Manual:IP/DHCP Relay"

From MikroTik Wiki
Jump to navigation Jump to search
Line 127: Line 127:


Revision as of 10:07, 12 March 2010


Applies to RouterOS: v3, v4


DHCP Relay is just a proxy that is able to receive a DHCP request and resend it to the real DHCP server.


Sub-menu: /ip dhcp-client

Property Description
delay-threshold (time; 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: The unique IP address of this DHCP relay needed for DHCP server to distinguish relays. If set to - the IP address will be chosen automatically
name (string; Default: ) Descriptive name for relay

DHCP relay does not choose the particular DHCP server in the dhcp-server list, it just send the incoming request to all the listed servers.

Example setup

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 relies DHCP requests from clients to DHCP server.

This example will show you how to configure a DHCP server and a DHCP relay which serve 2 IP networks - and that are behind a router DHCP-Relay.


IP addresses of DHCP-Server:

[admin@DHCP-Server] ip address> print
Flags: X - disabled, I - invalid, D - dynamic
 #   ADDRESS            NETWORK         BROADCAST       INTERFACE
 0   To-DHCP-Relay
 1	Public
[admin@DHCP-Server] ip address>

IP addresses of DHCP-Relay:

[admin@DHCP-Relay] ip address> print
Flags: X - disabled, I - invalid, D - dynamic
 #   ADDRESS            NETWORK         BROADCAST       INTERFACE
 0   To-DHCP-Server
 1   Local1
 2   Local2
[admin@DHCP-Relay] ip address>

To setup 2 DHCP Servers on DHCP-Server router add 2 pools. For networks and

/ip pool add name=Local1-Pool ranges=
/ip pool add name=Local1-Pool ranges=
[admin@DHCP-Server] ip pool> print
 # NAME                                         RANGES
 0 Local1-Pool                        
 1 Local2-Pool                        
[admin@DHCP-Server] ip pool>

Create DHCP Servers:

/ip dhcp-server add interface=To-DHCP-Relay relay= \
   address-pool=Local1-Pool name=DHCP-1 disabled=no
/ip dhcp-server add interface=To-DHCP-Relay relay= \
   address-pool=Local2-Pool name=DHCP-2 disabled=no
[admin@DHCP-Server] ip dhcp-server> print
Flags: X - disabled, I - invalid
 0   DHCP-1       To-DHCP-Relay     Local1-Pool  3d00:00:00
 1   DHCP-2       To-DHCP-Relay     Local2-Pool  3d00:00:00
[admin@DHCP-Server] ip dhcp-server>

Configure respective networks:

/ip dhcp-server network add address= gateway= \
/ip dhcp-server network add address= gateway= \
[admin@DHCP-Server] ip dhcp-server network> print
[admin@DHCP-Server] ip dhcp-server network>

Configuration of DHCP-Server is done. Now let's configure DHCP-Relay:

/ip dhcp-relay add name=Local1-Relay interface=Local1 \
   dhcp-server= local-address= disabled=no
/ip dhcp-relay add name=Local2-Relay interface=Local2 \
   dhcp-server= local-address= disabled=no
[admin@DHCP-Relay] ip dhcp-relay> print
Flags: X - disabled, I - invalid
 #   NAME                        INTERFACE      DHCP-SERVER     LOCAL-ADDRESS
 0   Local1-Relay                Local1
 1   Local2-Relay                Local2
[admin@DHCP-Relay] ip dhcp-relay>

[Back to Content]