Giter Site home page Giter Site logo

Comments (12)

martin-ger avatar martin-ger commented on July 17, 2024

Since release 2.6.0 NAPT/NAT is part of the standard distribution. See also this example: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/RangeExtender-NAPT/RangeExtender-NAPT.ino

Okay, that's ESP8266, not ESP32... (don't know about ESP32)

from esp32_nat_router.

zekageri avatar zekageri commented on July 17, 2024

oh god how good it would be

from esp32_nat_router.

martin-ger avatar martin-ger commented on July 17, 2024

Guess you can do that using Arduino as a component of the ESP-IDF: https://github.com/espressif/arduino-esp32/blob/master/docs/esp-idf_component.md
In the IDF menuconfig use these setting also:
https://github.com/martin-ger/esp32_nat_router#building-the-binaries

from esp32_nat_router.

zekageri avatar zekageri commented on July 17, 2024

I'm gonna check on this! Thanks.

from esp32_nat_router.

paclema avatar paclema commented on July 17, 2024

Do you have some hints on how to integrate that like in the esp8266 release 2.6.0? I want to add this functionality to some other project that it is using platformio, but I am not sure how to compile your code and make it accessible to platformio exactly.

Thank you!

from esp32_nat_router.

martin-ger avatar martin-ger commented on July 17, 2024

The NAT feature is actually included in ESP8266 Arduino, have a look here:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/RangeExtender-NAPT/RangeExtender-NAPT.ino

from esp32_nat_router.

paclema avatar paclema commented on July 17, 2024

Thank you @martin-ger ! This is exactly what I want to approach but for the ESP32, not for the ESP8266, but for the ESP32 the lwip libraries are not available like in this example and I am not sure how to integrate them.

Do you know how could I make your awesome libraries accessible to Arduino core for the ESP32?

from esp32_nat_router.

martin-ger avatar martin-ger commented on July 17, 2024

Okay, I understand. The later ESP32 Arduino core includes the lwip_napt.h from the esp-idf ( https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/lwip_napt.h ).

So I guess it is included in liblwip and you can just include and call it. Haven't tried this so far.

If not, the libs are built without this option on. Then I would try to build the lib with esp-idf an copy it over.

from esp32_nat_router.

paclema avatar paclema commented on July 17, 2024

Thank you @martin-ger for your tips! As you mention, I had to re-build esp-idf libs after enabling IP forwarding and NAT so I can access to lwip_napt.h added in the latest ESP32 Arduino core.

I have created this example esp32_lwip_nat_example using my fork for arduino-esp32 framework where I have enabled the LWIP lib. It compiles successfully, however, it is still missing the last part to provide DNS to dhcp server. It looks that the core also contains the dhcpserver however if I try to call the dhcps_set_option_info() and dhcps_dns_setserver() functions, the compiler fails to link the libraries giving the errors:

undefined 
reference to `dhcps_set_option_info(unsigned char, void*, unsigned int)'
undefined 
reference to `dhcps_dns_setserver(ip_addr const*)'

With this example, I can connect the esp32 as a station and I can also connect devices to it, but they don't get internet connection.

Do you know how could I also configure the AP dns to fit with the station dns?

from esp32_nat_router.

martin-ger avatar martin-ger commented on July 17, 2024

Does it change anything if you include "dhcpserver/dhcpserver.h" and "dhcpserver/dhcpserver_options.h" as "extern "C" { ... }?

from esp32_nat_router.

paclema avatar paclema commented on July 17, 2024

I think that the libraries are included correctly directly here (no errors while compiling) but I tried adding:

extern "C" {
  #include "dhcpserver/dhcpserver.h"
  #include "dhcpserver/dhcpserver_options.h"
}

And it also includes the libraries correctly but if I uncomment the functions dhcps_set_option_info and dhcps_dns_setserver I still get the linking errors.

I am not sure if this lwip/apps/dhcpserver/dhcpserver.c is perhaps not added correctly into the sdk libraries?

from esp32_nat_router.

paclema avatar paclema commented on July 17, 2024

I have found the solution to accomplish the last part to provide DNS to DHCP server. The solution is described in this arduino-esp32 issue #5117.

You can also check the working example at this repo: esp32_lwip_nat_example

from esp32_nat_router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.