esphome / esphome/feature-requests
Add support for receiving DHCP option 121 in DHCP client (Ethernet and WIFI)
- Dominant language
- No language data
- Stars
- 450
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem you have/What new integration you would like**
I would like support for DHCP option 121 in the DHCP client implementation used by ESPHome (Ethernet and WIFI).
DHCP option 121 is defined in [RFC3442](https://datatracker.ietf.org/doc/html/rfc3442). It's called **Classless Static Route**.
It enables a DHCP server to push static CIDR routes to a DHCP client.
**Please describe your use case for this integration and alternatives you've tried:**
ESPHome supports static IP configuration, but many people may use static (or dynamic) DHCP lease instead because it provides more flexibility (no need to flash if one's network topology changes).
Sometimes, we want to restrict ESPHome communication with the outside world.
In my case ESPHome is served by DHCP (static lease), but I don't want to give a default gateway nor a DNS to it. I don't want it to send all its packets to a gateway. I only want it to have a `/32` route to one IP, and telling it "trust me, this is in your scope link, just do ARP, there is no nexthop" required. This slash is not in its own slash.
This has the benefit of ESPHome unable to send "ANY" packet to a gateway. For a general packet, it won't know to who to send it to (no default route) and will have to drop it. And it will only be able to respond to the host establishing a connection to it (thanks to the link scope /32 route), it will know "okay, this is on my link, I can figure out the MAC address and respond directly).
DHCP Option 121 provides a way to push routes to a client. They can be normal routes (with a nexthop), but if the nexthop is set to `0.0.0.0`, this is to be interpreted as no nexthop (route scope link, e.g. use ARP in case of IPv4). I find this property of the DHCP option 121 very interesting.
I've tried pushing options 121 and 33 but ESPHome doesn't seem to react to it.
**Additional context**
Even though my use case may seem specific, some people may need to push routes **additionally** to the default gateway one.
I happen not wanting to send a default route, but that may not be the only use case for supporting DHCP option 121.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the DHCP client implementation used by ESPHome for Ethernet and WiFi, then read RFC3442 to understand the Classless Static Route format and its no-next-hop case. The feature is done when DHCP option 121 routes are accepted and applied for both connection types, including routes pushed alongside or instead of a default gateway.
Written by the indexing model from the issue text.
Assessment
- Domain
- embedded-iot, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100