Manual:IP/DHCP Relay: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
mNo edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Versions|v3, v4}}
{{Versions|v3, v4 +}}


<div class=manual>
__TOC__
 
 
==Summary==


<h2>Summary</h2>
<p>
DHCP Relay is just a proxy that is able to receive a DHCP request and resend it to the real DHCP server.
DHCP Relay is just a proxy that is able to receive a DHCP request and resend it to the real DHCP server.
</p>


<h2>Properties</h2>
<p><b>Sub-menu:</b> <code>/ip dhcp-client</code></p>


<table class="styled_table">
==Properties==
<tr>
<p id="shbox"><b>Sub-menu:</b> <code>/ip dhcp-relay</code></p>
  <th width="40%">Property</th>
 
  <th >Description</th>
 
</tr>
{{Mr-arg-table-h
<tr>
|prop=Property
    <td><var><b>delay-threshold</b></var> (<em>time</em>; Default: <b>none</b>)</td>
|desc=Description
    <td>If secs field in DHCP packet is smaller than delay-threshold, then this packet is ignored</td>
}}
</tr>
 
<tr>
{{Mr-arg-table
    <td><var><b>dhcp-server</b></var> (<em>string</em>; Default: <b></b>)</td>
|arg=add-relay-info
    <td>List of DHCP servers' IP addresses which should the DHCP requests be forwarded to</td>
|type=yes {{!}} no
</tr>
|default=no
<tr>
|desc=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.
    <td><var><b>interface</b></var> (<em>string</em>; Default: <b></b>)</td>
}}
    <td>Interface name the DHCP relay will be working on.</td>
 
</tr>
{{Mr-arg-table
<tr>
|arg=delay-threshold
    <td><var><b>local-address</b></var> (<em>IP</em>; Default: <b>0.0.0.0</b>)</td>
|type=time {{!}} none
    <td>The unique IP address of this DHCP relay needed for DHCP server to distinguish relays. If set to <b>0.0.0.0</b> - the IP address will be chosen automatically</td>
|default=none
</tr>
|desc=If secs field in DHCP packet is smaller than delay-threshold, then this packet is ignored
<tr>
}}
    <td><var><b>name</b></var> (<em>string</em>; Default: <b></b>)</td>
 
    <td>Descriptive name for relay</td>
{{Mr-arg-table
</tr>
|arg=dhcp-server
</table>
|type=string
|default=
|desc=List of DHCP servers' IP addresses which should the DHCP requests be forwarded to
}}
 
{{Mr-arg-table
|arg=interface
|type=string
|default=
|desc=Interface name the DHCP relay will be working on.
}}
 
{{Mr-arg-table
|arg=local-address
|type=IP
|default=0.0.0.0
|desc=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
}}
 
{{Mr-arg-table
|arg=relay-info-remote-id
|type=string
|default=
|desc=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'''
}}
 
{{Mr-arg-table-end
|arg=name
|type=string
|default=
|desc=Descriptive name for the relay
}}
 
 


<p>
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.
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.
</p>


<h2>Example setup</h2>
==Example setup==
<p>
 
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.
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.
</p>
 
<p>
This example will show you how to configure a DHCP server and a DHCP relay which serve 2 IP networks - 192.168.1.0/24 and 192.168.2.0/24 that are behind a router DHCP-Relay.
This example will show you how to configure a DHCP server and a DHCP relay which serve 2 IP networks - 192.168.1.0/24 and 192.168.2.0/24 that are behind a router DHCP-Relay.
</p>
 
[[Image:dhcp-relay.png]]
[[Image:dhcp-relay.png | center]]
<p>
 
'''IP Address Configuration'''
 
IP addresses of DHCP-Server:
IP addresses of DHCP-Server:
<pre>
<pre>
Line 66: Line 96:
Flags: X - disabled, I - invalid, D - dynamic
Flags: X - disabled, I - invalid, D - dynamic
  #  ADDRESS            NETWORK        BROADCAST      INTERFACE
  #  ADDRESS            NETWORK        BROADCAST      INTERFACE
  0  192.168.0.1/24    192.168.0.0    192.168.0.255  To-DHCP-Server
  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
  1  192.168.1.1/24    192.168.1.0    192.168.1.255  Local1
  2  192.168.2.1/24    192.168.2.0    192.168.2.255  Local2
  2  192.168.2.1/24    192.168.2.0    192.168.2.255  Local2
[admin@DHCP-Relay] ip address>
[admin@DHCP-Relay] ip address>
</pre>
</pre>
'''DHCP Server Setup'''


To setup 2 DHCP Servers on DHCP-Server router add 2 pools. For networks 192.168.1.0/24 and 192.168.2.0:
To setup 2 DHCP Servers on DHCP-Server router add 2 pools. For networks 192.168.1.0/24 and 192.168.2.0:
Line 109: Line 141:
[admin@DHCP-Server] ip dhcp-server network>
[admin@DHCP-Server] ip dhcp-server network>
</pre>
</pre>
'''DHCP Relay Config'''


Configuration of DHCP-Server is done. Now let's configure DHCP-Relay:
Configuration of DHCP-Server is done. Now let's configure DHCP-Relay:
Line 124: Line 158:
</pre>
</pre>


<nowiki>[</nowiki>[[#content|Back to Content]]<nowiki>]</nowiki>
 
{{cont}}


[[Category:Manual|D]]
[[Category:Manual|D]]
[[Category:DHCP|R]]
[[Category:DHCP|R]]
[[Category:IP|D]]
[[Category:IP|D]]

Latest revision as of 10:45, 28 July 2016

Version.png

Applies to RouterOS: v3, v4 +


Summary

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


Properties

Sub-menu: /ip dhcp-relay


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


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 - 192.168.1.0/24 and 192.168.2.0/24 that are behind a router DHCP-Relay.

Dhcp-relay.png

IP Address Configuration

IP addresses of DHCP-Server:

[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-Relay:

[admin@DHCP-Relay] 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   192.168.1.1/24     192.168.1.0     192.168.1.255   Local1
 2   192.168.2.1/24     192.168.2.0     192.168.2.255   Local2
[admin@DHCP-Relay] ip address>

DHCP Server Setup

To setup 2 DHCP Servers on DHCP-Server router add 2 pools. For networks 192.168.1.0/24 and 192.168.2.0:

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

Create DHCP Servers:

/ip dhcp-server add interface=To-DHCP-Relay relay=192.168.1.1 \
   address-pool=Local1-Pool name=DHCP-1 disabled=no
/ip dhcp-server add interface=To-DHCP-Relay relay=192.168.2.1 \
   address-pool=Local2-Pool name=DHCP-2 disabled=no
[admin@DHCP-Server] ip dhcp-server> print
Flags: X - disabled, I - invalid
 #   NAME         INTERFACE     RELAY           ADDRESS-POOL LEASE-TIME ADD-ARP
 0   DHCP-1       To-DHCP-Relay 192.168.1.1     Local1-Pool  3d00:00:00
 1   DHCP-2       To-DHCP-Relay 192.168.2.1     Local2-Pool  3d00:00:00
[admin@DHCP-Server] ip dhcp-server>

Configure respective networks:

/ip dhcp-server network add address=192.168.1.0/24 gateway=192.168.1.1 \
   dns-server=159.148.60.20
/ip dhcp-server network add address=192.168.2.0/24 gateway=192.168.2.1 \
   dns-server 159.148.60.20
[admin@DHCP-Server] ip dhcp-server network> print
 # ADDRESS            GATEWAY         DNS-SERVER      WINS-SERVER     DOMAIN
 0 192.168.1.0/24     192.168.1.1     159.148.60.20
 1 192.168.2.0/24     192.168.2.1     159.148.60.20
[admin@DHCP-Server] ip dhcp-server network>

DHCP Relay Config

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

/ip dhcp-relay add name=Local1-Relay interface=Local1 \
   dhcp-server=192.168.0.1 local-address=192.168.1.1 disabled=no
/ip dhcp-relay add name=Local2-Relay interface=Local2 \
   dhcp-server=192.168.0.1 local-address=192.168.2.1 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         192.168.0.1     192.168.2.1
[admin@DHCP-Relay] ip dhcp-relay>


[ Top | Back to Content ]