lwip local port forwarding enabled files attached
Posted: Sat Feb 19, 2022 5:59 am
I needed the ability to port forward back onto the same network but the current lwip files as of ESP-IDF 4.4.0 do not support this. The attached files add this capability to lwip. I built an ESP32LocalPortForwarder app that provides a web interface to manage port forward rules using these updated lwip files (https://github.com/mtnbkr88/ESP32LocalPortForwarder). Copy the attached files to the these locations to enable local port forwarding:
ESP-IDF\components\lwip\lwip\src\core\ipv4\ip4.c
ESP-IDF\components\lwip\lwip\src\core\ipv4\ip4_napt.c
ESP-IDF\components\lwip\lwip\src\include\lwip\ip4_napt.h
I also had to modify opt.h and enable the below because menuconfig does not support enabling all these options:
#define IP_FORWARD 1
#define IP_NAPT 1
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 1
Please add these changed files to future versions of lwip so local port forwarding will be available if needed.
ESP-IDF\components\lwip\lwip\src\core\ipv4\ip4.c
ESP-IDF\components\lwip\lwip\src\core\ipv4\ip4_napt.c
ESP-IDF\components\lwip\lwip\src\include\lwip\ip4_napt.h
I also had to modify opt.h and enable the below because menuconfig does not support enabling all these options:
#define IP_FORWARD 1
#define IP_NAPT 1
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 1
Please add these changed files to future versions of lwip so local port forwarding will be available if needed.