I have an ESP32 wroom32 that has WiFi internally and an ethernet port. I want to be able to connect my phone to the WiFi and access a webserver running on the ethernet port. Schematically this looks like:
PC ----------------------- ETH (ESP32) <----NAT?----> Wifi (ESP32)------------ Phone
The PC has static IP: 192.168.2.150
ETH (ESP32) has static ip 192.168.2.100
Wifi (ESP) has dhcp enabled, subnet: 192.168.4.x
I am able to configure the Wifi and the ethernet part to initialize. The ETH side has a static ip and the Wifi side has DHCP to assign an IP to the phone.
I use ESP-IDF running RTOS framework to develop my application. And I have been searching the internet for possible solutions to this problem. I have found suggestions that to connect both interfaces (ETH and Wifi) I need something like NAT running on the ESP. However there is no current implementation of this.
I only want to access a specif webserver page running on the PC (access through 192.168.2.150:8000), this makes me think that it should be possible to have a very simple forwarding function that forwards between Wifi and ETH.
At the moment I am not sure how to start. If my idea is even possible or if there are alternatives to implement what I want.
Final: I have been able to implement the ETH2Wifi example, but this connect both interfaces and disabling the functionality of the access point (https://github.com/espressif/esp-iot-so ... s/eth2wifi)
Simple NAT implementation
-
- Posts: 27
- Joined: Thu Sep 07, 2017 10:26 am
Re: Simple NAT implementation
I think you could just use the LWIP RAW API to forward the packets back and forth between ethernet and wifi interfaces. Just filter out the packets you don't need. You might need to change the IP address in the packet buffer as well. Shouldn't be too difficult once you figure out how to use the API.
Re: Simple NAT implementation
Hi,
I know this is quite an old post, but I have the same issue: I need to implement a wireless gateway.
Basically, I'll have a local WiFi network (ESP32 as AP), and an external GPRS modem connected
to the ESP32 to access the cloud.
I have seen that the link (https://github.com/espressif/esp-iot-so ... s/eth2wifi) is no more valid.
Is there any example code? Did someone succeed to implement the "gateway" functionality on ESP32? Any suggestion?
Btw, I am using the "esp32-arduino" wrapper, but maybe it should be possible to also use directly esp-idf methods
(so also an esp-idf example code/lib could be fine).
Thank you.
Regards.
I know this is quite an old post, but I have the same issue: I need to implement a wireless gateway.
Basically, I'll have a local WiFi network (ESP32 as AP), and an external GPRS modem connected
to the ESP32 to access the cloud.
I have seen that the link (https://github.com/espressif/esp-iot-so ... s/eth2wifi) is no more valid.
Is there any example code? Did someone succeed to implement the "gateway" functionality on ESP32? Any suggestion?
Btw, I am using the "esp32-arduino" wrapper, but maybe it should be possible to also use directly esp-idf methods
(so also an esp-idf example code/lib could be fine).
Thank you.
Regards.
Who is online
Users browsing this forum: No registered users and 92 guests