I have two routers with built-in Wireguard capability, and they are connected. The HA server is in the 192.168.10.x network, and the ESPome node is in the 192.168.20.x network. I know mDNS is not routed across, but I naively thought I could just specify the static IP address of the HA server on the ESPHome node and that would be it. It seems there is no way to do that? Could I patch the sources, or is it not that simple?
I also manually added the ESPHome node in HA, and it recognised something, but still it is not displayed as being online. I know I could use MQTT as a workaround, but that seem rather unnecessary?
Router 1 (192.168.10.x) should have: AllowedIPs 192.168.20.0/24
Router 2 (192.168.20.x) should have: AllowedIPs 192.168.10.0/24
What that will do is add a route from router 1 to addresses in Router 2 and vice versa.
Now you don’t have to route the whole network, if Router 2 is only communicating with home assistant then you can just use ex. 192.168.10.100/32 (use the correct IP for HA).
Then all traffic from Router 2 to HA should be routed and all traffic back from HA to the node(s) should be routed back to Router 2
According to your description, that should be correct?
I noticed that I can reach 192.168.10.1 from 192.168.20.x, but I can’t reach 192.168.20.1 from 192.168.10.x. This explains why Home Assistant, which lives in 192.168.10, gets no updates from the ESPHome node in 192.168.20.x. The WireGuard Tunnel is basically unidirectional, and I don’t understand why.
Update: I think my ISP uses CGNAT, maybe this is causing issues.
I checked how I have set up my wireguard from my phone to my router.
On the router I have
10.10.1.1/24
and all peers has one ip each in the same net for allowIPs
10.10.1.20/32
On the phone I have address 10.10.1.20/32
And allowedIPs 0.0.0.0/0 as all traffic will go to my VPN.
Looking at your config, maybe your main router (Router 1) should have one extra AllowIPs set to ex. 192.168.10.250/32
Then your Router 2 under interface have address = 192.168.10.250/32 instead of 192.168.20.1/24
under peer you leave it as it is.
Your Router 2 will have its own dhcp under the LAN with 192.168.20.1/24.
then all traffic from 192.168.20.x will be routed into Router 2 and there it will find the route though the WG interface.
Maybe test this?
You may need to set firewall rules also. so check that too.
So I’ve changed the IP from CGNAT to a proper one, and now it seems to work. I can’t tell for sure if this is what did it, but the main takeaway is that you don’t need mDNS to add an ESPHome device, its just convenient - you can always add it manually by its IP address.
Beside mDNS hostname or IP address the normal/traditional hostname is also allowed and often makes sense when working with different (sub)nets and domains