How to get IP address to pass to htonl() #9742
-
I am basically copying the code inside esp_ifconfig in modnetwork.c to a new method to enable NAT
the ifconfig is set to to 192.168.5.1 on the AP_IF - how do I get this value from the info variable to pass it to the below function? ip_napt_enable(htonl(napt_netif_ip), 1); I have tried to print the IP address from the variable info, but it is not the right value
It prints out a value of 395811, where as the correct value should be 3232236801 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
What has this to do with micropython ? |
Beta Was this translation helpful? Give feedback.
-
Just for anyone who may be interested in enabling NAT on their ESP32 Add this to your modenetwork.c located in /ports/esp32
Add this line to modnetwork.h
Once you build it and flash it, connect STA to a working router, set your ifconfig parameters on AP_IF correctly to include a DNS server for ex ('192.168.5.1','255.255.255.0','192.168.5.1','8.8.8.8'). Then you can call network.WLAN(network.AP_IF).nat_enable() and any devices connected to ESP32 AP will be able connect to the internet. |
Beta Was this translation helpful? Give feedback.
-
This would be an really awesome feature to include, pull request? |
Beta Was this translation helpful? Give feedback.
Just for anyone who may be interested in enabling NAT on their ESP32
Add this to your modenetwork.c located in /ports/esp32