DHCP relay principle
1 When the dhcp client starts and initializes dhcp, it broadcasts the configuration request packets on the local network. 2. If the local network has a dhcp server, you can directly configure dhcp without the need for dhcp relay. 3. If the local network does not have a dhcp server, the network settings with the dhcprelay function connected to the local network
After receiving the broadcast packet, the slave instance forwards the packet to the dhcp server on the specified network. 4. the dhcp server configures the dhcp client based on the information provided by the dhcp client, and sends the configuration information to the dhcp client through dhcp relay to complete the dynamic configuration of the dhcp client. In fact, from the beginning to the end to complete the configuration, there need to be multiple such interaction processes. The message interaction process is as follows:
The dhcp relay device modifies the corresponding fields in the dhcp message, changes the dhcp broadcast packet to a unicast packet, and is responsible for switching between the server and the client.
--------------------------------------------------
Http://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Relay
Manual: IP/DHCP Relay
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 shocould the DHCP requests be forwarded |
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 set0.0.0.0-The IP address will be chosen automatically |
Name(String; Default :) |
Descriptive name for the relay |
DHCP relay does not choose the participating 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.
IP Address Configuration
IP addresses of DHCP-Server:
[admin@DHCP-Server] ip address> printFlags: 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/2410.1.0.010.1.0.255Public[admin@DHCP-Server] ip address>
IP addresses of DHCP-Relay:
[admin@DHCP-Relay] ip address> printFlags: 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> printFlags: 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> printFlags: 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>