Discussion:
[Dnsmasq-discuss] Problem with dhcp relay function
André Valentin
2016-10-28 08:53:36 UTC
Permalink
Hi !

I had a problem using the dhcp relay in dnsmasq. If a reply comes in from the upstream DHCP Server,
it has always been sent back on the receiving interface. Correct is the interface with the
corresponding network/ip configuration.

This patch helped:
diff --git a/src/dhcp.c b/src/dhcp.c
index fb2f650..9b4e9bc 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -417,6 +417,11 @@ void dhcp_packet(time_t now, int pxe_fd)
if (ioctl(daemon->dhcpfd, SIOCSARP, &arp_req) == -1)
my_syslog(MS_DHCP | LOG_ERR, _("ARP-cache injection failed: %s"), strerror(errno));
}
+ /* This is a reply that is to be relayed, unset target interface
+ to enforce routing. */
+ if (is_relay_reply) {
+ pkt->ipi_ifindex = 0;
+ }
}
#elif defined(HAVE_SOLARIS_NETWORK)
else if ((ntohs(mess->flags) & 0x8000) || mess->hlen != ETHER_ADDR_LEN || mess->htype != ARPHRD_ETHER)

Please take a look if I solved it right. If needed, I can resend the patch with git send-email.

Kind regards,

André

Loading...