esp32_nat_router icon indicating copy to clipboard operation
esp32_nat_router copied to clipboard

Static routing in mesh network

Open jigneshpatel47 opened this issue 3 years ago • 6 comments

Hi,

I have created mesh on esp32c3 taken a reference from wifi repeater. Thank you @martin-ger for this. We are using esp-idf revsion ESP-IDF v4.3-beta3-dirty. I have enable napt using ip_napt_enable(htonl(napt_netif_ip), 1); for packet forwarding.

I am able to ping and connect TCP port to root from a client that is connected to child node but I can not ping to child node from the client which is connected to root. I have attached a mesh diagram for reference Esp_mesh

Please help how to connect from root to child node.

Thank you, Jignesh Patel

jigneshpatel47 avatar Aug 03 '21 12:08 jigneshpatel47

Thank you for this.

dherkes avatar Aug 03 '21 13:08 dherkes

192.168.3.2 is the child? You cannot connect in that direction through a NAT router. The only option is port forwarding but this has to be configured on all downstream routers and it can only be done for one device per port number.

This is a reason why I did the MQTT-VPN: https://github.com/martin-ger/MQTT_VPN

martin-ger avatar Aug 03 '21 13:08 martin-ger

Yes, 192.168.3.2 are child node.

jigneshpatel47 avatar Aug 03 '21 16:08 jigneshpatel47

Hi,

Is there any other way to connect the child from the root node? any idea will be appreciated.

Thank you, Jignesh Patel

jigneshpatel47 avatar Aug 04 '21 05:08 jigneshpatel47

As said above: to connnect to a node behind a NAT router you either need a port forward (difficult if you have several levels of NAT and many nodes): portmap [add|del] [TCP|UDP] <ext_portno> <int_ip> <int_portno>

or the connection is set up the other way round. That's why I started with MQTT-VPN: https://github.com/martin-ger/MQTT_VPN.

The idea of this project is to enable bidirectional IP connectivity, where it is not available otherwise, e.g. if one node is hidden behind (several layers of) NAT. This is the case in most private networks and also in mobile IP networks. Prerequisite is, that all connected nodes can reach a common MQTT broker. This allows you to "dial-in" into an IoT device sitting anywhere in the internet.

Any other VPN/tunneling Protocol might work also...

martin-ger avatar Aug 04 '21 06:08 martin-ger

Thank you @martin-ger.

I will check into it.

Best Regards, Jignesh Patel

jigneshpatel47 avatar Aug 04 '21 08:08 jigneshpatel47