Jump to content

DHCP Relay configuration example: Difference between revisions

From Teltonika Networks Wiki
No edit summary
No edit summary
Tags: Mobile edit Mobile web edit
 
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Introduction==
<p style="color:red">The information on this page is updated in accordance with the [https://wiki.teltonika-networks.com/view/FW_%26_SDK_Downloads'''00.07.13.4'''] firmware version .</p>
'''DHCP Relay''' is a router that forwards IP addresses from the DHCP Server to the user devices, even if the server is on a different network. The main benefit of this approach is that a single DHCP Server can distribute IP addresses to multiple networks. Bellow you will find an example of how to configure a basic DHCP Relay configuration.
===Introduction===
----
DHCP Relay is a router that forwards IP addresses from the DHCP Server to the user devices, even if the server is on a different network. The main benefit of this approach is that a single DHCP Server can distribute IP addresses to multiple networks. Bellow you will find an example of how to configure a basic DHCP Relay configuration.
===Prerequisites & Topology===
----
====Prerequisites====
#For this configuration you will need 2 routers. One as a DHCP Server and the other as a DHCP Relay.
#DHCP Relay device WAN port needs to be connected to DHCP server LAN port.


==Configuration overview and prerequisites==
====Topology====
----
DHCP server network settings:
LAN IP/subnet: 192.168.4.1/24
 
DHCP Relay network settings:
 
LAN IP/subnet: 192.168.2.1/24
WAN IP: 192.168.4.194
 
The DHCP relay service enables the forwarding of DHCP broadcast messages to network segments that a client computer is not directly connected to. It allows a single DHCP server to be shared across different logical network segments separated by a firewall. Unlike handling IP addresses, the DHCP relay service sends unicast messages rather than broadcast messages.
 
When a client needs a DHCP-assigned IP address, it broadcasts a request to the network attached to its interface. The DHCP relay service on the firewall intercepts this request on an interface connected to the same network, such as LAN 192.168.2.0/24. The relay service then unicasts the request to all configured DHCP servers in the LAN and receives an IP address offer from a DHCP server (e.g., 192.168.4.1) that has a range of addresses configured for the client's network segment (e.g., 192.168.2.0/24). This offer is forwarded to the client. If the client accepts the offer, it acknowledges the DHCP address and assigns it to its interface immediately.
 
[[File:708576_Topo.png|border|class=tlt-border| center|1000px]]


For this configuration you will need 2 routers. One as a DHCP Server and the other as a DHCP Relay
====DHCP Server Configuration====
----
=====LAN Configuration=====
Open router’s '''WebUI → Network → LAN''' click [[File:Pencil2.png]]on current available LAN interface configuration:


'''Prerequisites:'''
======General Settings======
----
Make the following changes:
# Enter IPv4 address: '''192.168.4.1'''


DHCP Relay device WAN port needs to be connected to DHCP server LAN port
[[File:DHCP_RELAY_1_1_1_1.png|border|class=tlt-border|center]]


DHCP Relay network settings:
=====Lease Configuration=====
----
Open router’s '''WebUI → System → Mantenance → CLI'''


LAN IP/subnet: 192.168.2.1/24
Enter this command to CLI:
WAN IP: 192.168.4.194


DHCP server network settings:
echo "dhcp-range=192.168.2.100,192.168.2.200,12h" >> /etc/dnsmasq.conf


LAN IP/subnet: 192.168.4.1/24
[[File:DHCP_RELAY_2_1.png|border|class=tlt-border|center|1100px]]


'''Configuration scheme:'''
=====Static Route Configuration=====
----
Open '''WebUI → Network → Routing → Static routes'''


[[File:Networking_rutx_manual_lan_static_dhcp_server_relay_scheme_v2.png|border|class=tlt-border]]
======Static IPv4 Routes======
----
click [[File:Add Button.png|40x70px]] and apply this to the route:
#Select Interface: ''' lan''' | Enter Target: '''192.168.2.0''' | Enter IPv4-Netmask: '''255.255.255.0''' | Enter IPv4-Gateway: '''192.168.4.194'''


[[File:DHCP_RELAY_3.png|border|class=tlt-border|center|1100px]]


==Configuration Steps==
====DHCP Relay Configuration====
----
=====Relay WAN Confiuration=====
----
Open router’s '''WebUI → Network → WAN → WAN interfaces''' click [[File:Pencil2.png]]current available WAN interface configuration:
======General Settings======
----
Make the following changes:


1. Enable DHCP Relay feature on device which will relay DHCP requests. In WebUI navigate to '''Network -> Interface -> LAN -> DHCP Server''' and change '''Enable DHCP''' field value from Enable to Relay and then type in the DHCP Server IP and click on Save & Apply.
# Select Protocol: '''Static'''
# Enter IPv4 address: '''192.168.4.194'''


[[File:Networking_rutx_manual_lan_static_dhcp_server_dhcp_relay_configuration_v1.png|border|class=tlt-border]]
[[File:DHCP_RELAY_7_1.png|border|class=tlt-border|center|1000px]]


2. Modify Enable-DHCP-renew firewall rule in '''Network -> Firewall -> Traffic rules''' to additionally allow destination port 67.
=====Relay LAN Confiuration=====
Open router’s '''WebUI → Network → LAN''' click [[File:Pencil2.png]]current available LAN interface configuration:
======General Settings======
----
Make the following changes:


[[File:Networking_rutx_manual_firewall_trafic_rules_configuration_for_dhcp_relay_v2.png|border|class=tlt-border]]
# Enter IPv4 address: '''192.168.2.1'''


3. DHCP Server must be able to assign addresses from 192.168.2.0/24 IP address pool. If DHCP Server is a Teltonika device running RUTOS then you can add this address pool via router's CLI by running command:
[[File:DHCP_RELAY_4_1_1.png|border|class=tlt-border|center]]


echo "dhcp-range=192.168.2.100,192.168.2.200,12h" >> /etc/dnsmasq.conf
=====Firewall Rule Configuration=====
Open router’s '''WebUI → Network → Firewall → Traffic Rules''' click [[File:Pencil2.png]] on Allow-DHCP-Renew rule:
======"Allow-DHCP-Renew" traffic rule configuration======
----
# Enter Destination Port: '''67'''


* 192.168.2.100 - specifies start of DHCP address pool range
[[File:DHCP_RELAY_3_1_1.png|border|class=tlt-border|center]]
* 192.168.2.200 - specifies end of DHCP address pool range
* 12h - specifies DHCP lease time


4. In this topology DHCP Server has no route to DHCP Relay's network so it must be added manually.
=====DHCP Replay Configuration=====
Static route can be added via '''Network -> Routing -> Static IPv4 routes'''.
----
Open router’s '''WebUI → Network → DHCP → Server Settings → IPv4 → DHCPv4 servers''' click [[File:Pencil2.png]]current available server interface configuration:
======"lan" DHCPv4 configuration======
----
Make the following changes:


[[File:Networking_rutx_manual_routing_ip4_static_routes_configuration_v2.png|border|class=tlt-border]]
# Enable: '''on'''
# Select DHCPv4 mode: '''Relay'''
# Enter DHCP server address: '''192.168.4.1'''


* Interface: Network interface where DHCP Relay resides
[[File:DHCP_RELAY_5_1.png|border|class=tlt-border|center|1000px]]
* Target: Network of DHCP Relay
* IPv4 netmask: Subnet of DHCP Relay network
* IPv4 Gateway: IP address of DHCP relay interface which is connected to DHCP Server


===Testing the configuration===
----
Navigate to the Open DHCP server's '''WebUI -> Status -> Network -> LAN'''. If the configuration is successful, the lease for the 192.168.2.0/24 network should be displayed in the WebUI DHCP lease list.


==Additional notes==
[[File:DHCP_RELAY_111111.png|border|class=tlt-border|center|1000px]]


===Additional notes===
----
'''Note:''' It's strongly recommended to use static IP configuration for DHCP Relay WAN interface otherwise there might be cases when WAN interface will receive new IP address which will cause static route to stop working.
'''Note:''' It's strongly recommended to use static IP configuration for DHCP Relay WAN interface otherwise there might be cases when WAN interface will receive new IP address which will cause static route to stop working.
[[Category:Router control and monitoring]]

Latest revision as of 11:00, 15 April 2025

Main Page > General Information > Configuration Examples > Router control and monitoring > DHCP Relay configuration example

The information on this page is updated in accordance with the 00.07.13.4 firmware version .

Introduction


DHCP Relay is a router that forwards IP addresses from the DHCP Server to the user devices, even if the server is on a different network. The main benefit of this approach is that a single DHCP Server can distribute IP addresses to multiple networks. Bellow you will find an example of how to configure a basic DHCP Relay configuration. ​

Prerequisites & Topology


Prerequisites

  1. For this configuration you will need 2 routers. One as a DHCP Server and the other as a DHCP Relay.
  2. DHCP Relay device WAN port needs to be connected to DHCP server LAN port.

Topology


DHCP server network settings:

LAN IP/subnet: 192.168.4.1/24 

DHCP Relay network settings:

LAN IP/subnet: 192.168.2.1/24
WAN IP: 192.168.4.194

The DHCP relay service enables the forwarding of DHCP broadcast messages to network segments that a client computer is not directly connected to. It allows a single DHCP server to be shared across different logical network segments separated by a firewall. Unlike handling IP addresses, the DHCP relay service sends unicast messages rather than broadcast messages.

When a client needs a DHCP-assigned IP address, it broadcasts a request to the network attached to its interface. The DHCP relay service on the firewall intercepts this request on an interface connected to the same network, such as LAN 192.168.2.0/24. The relay service then unicasts the request to all configured DHCP servers in the LAN and receives an IP address offer from a DHCP server (e.g., 192.168.4.1) that has a range of addresses configured for the client's network segment (e.g., 192.168.2.0/24). This offer is forwarded to the client. If the client accepts the offer, it acknowledges the DHCP address and assigns it to its interface immediately.

DHCP Server Configuration


LAN Configuration

Open router’s WebUI → Network → LAN click on current available LAN interface configuration:

General Settings

Make the following changes:

  1. Enter IPv4 address: 192.168.4.1
Lease Configuration

Open router’s WebUI → System → Mantenance → CLI

Enter this command to CLI:

echo "dhcp-range=192.168.2.100,192.168.2.200,12h" >> /etc/dnsmasq.conf
Static Route Configuration

Open WebUI → Network → Routing → Static routes

Static IPv4 Routes

click and apply this to the route:

  1. Select Interface: lan | Enter Target: 192.168.2.0 | Enter IPv4-Netmask: 255.255.255.0 | Enter IPv4-Gateway: 192.168.4.194

DHCP Relay Configuration


Relay WAN Confiuration

Open router’s WebUI → Network → WAN → WAN interfaces click current available WAN interface configuration:

General Settings

Make the following changes:

  1. Select Protocol: Static
  2. Enter IPv4 address: 192.168.4.194
Relay LAN Confiuration

Open router’s WebUI → Network → LAN click current available LAN interface configuration:

General Settings

Make the following changes:

  1. Enter IPv4 address: 192.168.2.1
Firewall Rule Configuration

Open router’s WebUI → Network → Firewall → Traffic Rules click on Allow-DHCP-Renew rule:

"Allow-DHCP-Renew" traffic rule configuration

  1. Enter Destination Port: 67
DHCP Replay Configuration

Open router’s WebUI → Network → DHCP → Server Settings → IPv4 → DHCPv4 servers click current available server interface configuration:

"lan" DHCPv4 configuration

Make the following changes:

  1. Enable: on
  2. Select DHCPv4 mode: Relay
  3. Enter DHCP server address: 192.168.4.1

Testing the configuration


Navigate to the Open DHCP server's WebUI -> Status -> Network -> LAN. If the configuration is successful, the lease for the 192.168.2.0/24 network should be displayed in the WebUI DHCP lease list.

Additional notes


Note: It's strongly recommended to use static IP configuration for DHCP Relay WAN interface otherwise there might be cases when WAN interface will receive new IP address which will cause static route to stop working.