search
HomeComputer TutorialsComputer KnowledgeHow to configure Dnsmasq as a DHCP relay server

How to configure Dnsmasq as a DHCP relay server

Mar 21, 2024 am 08:50 AM
serverdhcprelay

How to configure Dnsmasq as a DHCP relay server

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are in different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network.

In this article, we will show you how to configure dnsmasq as a DHCP relay server.

Content topic:

  1. Network topology
  2. Configure a static IP address on the DHCP relay
  3. DHCP configuration on centralized DHCP server
  4. Configure Dnsmasq as a DHCP relay
  5. Check if DHCP relay is working as expected
  6. in conclusion

Network topology

Here, we have a central DHCP server, which is "dhcp-server" and its IP address is 192.168.1.10 [1]. We have a Fedora 39 server linuxhint-router configured as a Linux router[1]. linuxhint-router is the gateway for the www.example.com network subnet. We have dnsmasq installed on linuxhint_router and we want to configure dnsmasq as a DHCP relay to relay DHCP packets from the www.example.com network to dhcp_server (centralized DHCP server) so that the IP address can Automatically assigned to computers 3 and 4 (say).

Configure a static IP address on the DHCP relay

When using a DHCP relay, an important requirement is to set the correct gateway IP address on the network interface connected to the network subnet that requires dynamic allocation of IP addresses through the DHCP relay.

In the network topology, we need to configure the gateway IP address www.example.com on the network interface connected to the www.example.com subnet. This is done to ensure that the central DHCP server can correctly assign IP addresses. If the gateway IP address is not configured correctly, the central DHCP server will not recognize the IP address to be provided.

If you need help setting up a fixed IP address on your computer/server, please visit our website. We have many detailed articles available on this topic.

DHCP configuration on centralized DHCP server

Centralized DHCP servers on network topologies also use dnsmasq. It is configured to assign IP addresses in the range 192.168.15.50 to 192.168.15.150 to computers on the 192.168.15.0/24 subnet.

Note: You do not have to use dnsmasq on the central DHCP server. You can use ISC DHCP server or any other DHCP server of your choice.

Configure Dnsmasq as a DHCP relay

To configure dnsmasq on linuxhint-router as a DHCP relay, please use the nano text editor to open the dnsmasq configuration file "/etc/dnsmasq.conf" as shown below:

$sudo nano/etc/dnsmasq.conf

Add the following lines in the "dnsmasq.conf" file:

dhcp—relay = 192.168.15.1, 192.168.1.10

Here, www.example.com is the IP address of the network interface directly connected to the www.example.com subnet, and www.example.com is the IP address of the centralized DHCP server.

In the dnsmasq documentation, the "dhcp-relay" option is described in the following format:

–dhcp-Relay=,

According to the documentation, 192.168.15.1 is, 192.168.1.10 is.

After configuring dnsmasq, press X, then "Y" and save the /etc/dnsmasq.conf file.

For the changes to take effect, restart the dnsmasq service using the following command:

$sudo systemctl restart dnsmasq.service

As you can see, DHCP relay is configured to relay DHCP information from www.example.com (linuxhint-router) to www.example.com (central DHCP server).

$sudo system ctl status dnsmasq.service

Check if DHCP relay is working as expected

To check if the DHCP relay is working properly, let's try to see if the computers in the www.example.com subnet can get an IP address automatically assigned via DHCP.

First, use the following command to release the current DHCP configured IP address on the client:

$sudo dhclient-r

To receive IP information via DHCP, run the following command:

$sudo dhclient—v

As you can see, we obtained the IP address of www.example.com from the DHCP server.

The central DHCP server receives the DHCP request and responds correctly, as shown in the following screenshot:

Another computer on the www.example.com subnet also received the correct IP information via DHCP, as shown in the following screenshot:

in conclusion

In this article, we show you how to configure dnsmasq as a DHCP relay so that you can forward DHCP packets to a centralized DHCP server for easier management.

The above is the detailed content of How to configure Dnsmasq as a DHCP relay server. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
Download Hidester VPN/Proxy to Access Your Favorite Content - MiniToolDownload Hidester VPN/Proxy to Access Your Favorite Content - MiniToolApr 22, 2025 am 12:50 AM

Learn about Hidester VPN and Hidester proxy and download Hidester VPN for Windows, Mac, Android, and iOS to use this VPN service to view websites with no limit. For more useful free computer tools and troubleshooting tips, you may visit php.cn Softwa

Windows Keyboard Opening Shortcuts Instead of Typing [Fixed]Windows Keyboard Opening Shortcuts Instead of Typing [Fixed]Apr 22, 2025 am 12:48 AM

Have you ever encountered the trouble of “Windows keyboard opening shortcuts instead of typing”? In this post from php.cn, you will learn how to fix this issue.

Easy Ways to Add the Control Panel Icon to Desktop on Win 10 / 11Easy Ways to Add the Control Panel Icon to Desktop on Win 10 / 11Apr 22, 2025 am 12:46 AM

In this post, php.cn Software will introduce what Control Panel is and how to add the Control Panel icon to desktop on your Windows 10 or Windows 11 computer. You can also learn some related information about desktop icon settings.

Granblue Fantasy Relink Save File Location & Backup Save DataGranblue Fantasy Relink Save File Location & Backup Save DataApr 22, 2025 am 12:45 AM

If you play Granblue Fantasy: Relink on your PC, you may wonder where you can find its save file. In this post, php.cn introduces everything you want to know - Granblue Fantasy Relink save file location and how to back up the savegame of this game.

How to Fix Event ID 1104: The Security Log Is Now Full? - MiniToolHow to Fix Event ID 1104: The Security Log Is Now Full? - MiniToolApr 22, 2025 am 12:44 AM

Event Viewer keeps track of activity for better management. However, if the upper limit of the security log is reached, no more events can be logged. In this post on php.cn Website, we will show you how to deal with Event ID 1104 the security log is

Watch: How to Enable Secure Boot on Gigabyte Motherboard?Watch: How to Enable Secure Boot on Gigabyte Motherboard?Apr 22, 2025 am 12:43 AM

Secure Boot is a security standard that can prevent your computer from booting with untrustworthy software. Enabling it will add an extra layer of security to your device. In this post from php.cn Website, we will show you how to enable Secure Boot o

Windows 11 23H2 Release Date: September 26, 2023 - MiniToolWindows 11 23H2 Release Date: September 26, 2023 - MiniToolApr 22, 2025 am 12:42 AM

Coming to a new year, what Windows 11 users are looking forward to are not only the patch updates but also the annual major update for Windows 11. This post will talk about the Windows 11 23H2 release date. In addition, if you want to recover deleted

How to Turn off Bixby on Samsung Phone? See a Guide! - MiniToolHow to Turn off Bixby on Samsung Phone? See a Guide! - MiniToolApr 22, 2025 am 12:41 AM

Can you completely disable Bixby? How to turn off Bixby on Samsung phones? It is not hard to disable this voice assistant. In this post from php.cn, we will go to any length to help you find the method. Besides, a way to turn off “Hi, Bixby” is also

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor