Simple NAT implementation
Posted: Fri Feb 01, 2019 11:29 am
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)
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)