OpenWrt news, tools, tips and discussion. Related projects, such as DD-WRT, Tomato and OpenSAN, are also on-topic.
Set Up my router as a DHCP relay agent
I am working on a minor project task where I need to configure my router as a DHCP relay agent. What I have tried is
-
Ignored the current interface which was serving as DHCP agent by default.
-
Added the peice of code ( taken from OpenWRT documentation ) inside the dhcp file present inside /etc/config directory.
config relay 'id'
option interface 'lan'
option local_addr '192.168.1.1'
option server_addr 'remote_dhcp_server_ip'
The result is not what I am expecting.
I have a strict requirement to use version 21.02.0 of OpenWRT for this task. I think I'm missing something important. Any help would be greatly appreciated. Thanks.
Did you mange to get it work? I gave up on dnsmasq, and installed isc-dhcp-relay-ipv4. If you succeded, please share, so I can avoid that extra package.
I figured it out. You need
option interface 'wan' (if wan is the interace that can reach the dhcpserver)
or just skip the line:
#option interface 'whatever'
or empty interface:
option interface ''
Hopefully you have just masked the ip in option server_addr 'remote_dhcp_server_ip' - it must be an ip
From the manpage of dnsmasq:
**--dhcp-relay=<local address>[,<server address>[#<server port>]][,<interface]**Configure dnsmasq to do DHCP relay. The local address is an address allocated to an interface on the host running dnsmasq. All DHCP requests arriving on that interface will we relayed to a remote DHCP server at the server address. It is possible to relay from a single local address to multiple remote servers by using multiple --dhcp-relay configs with the same local address and different server addresses. A server address must be an IP literal address, not a domain name. If the server address is omitted, the request will be forwarded by broadcast (IPv4) or multicast (IPv6). In this case the interface must be given and not be wildcard. The server address may specify a non-standard port to relay to. If this is used then --dhcp-proxy should likely also be set, otherwise parts of the DHCP conversation which do not pass through the relay will be delivered to the wrong port.