Git Product home page Git Product logo

esp-idf-nat-example's Introduction

ESP-IDF example with WIFI and NAT setup

An example firmware to use the ESP32 as WiFi repeater.

Requires this lwIP library with NAT support to be used as ESP-IDF lwIP component: https://github.com/martin-ger/esp-lwip

Based on: https://github.com/espressif/esp-idf/blob/release/v3.3/examples/wifi/getting_started/softAP/

NAT-Setup (4) Example network setup using ESP32 as WiFi repeater. The diagram was created with Draw.io.

Get started

The following are the steps required to run this project on the ESP32 and turn it into a WiFi repeater. The example is for version 4.0 of ESP-IDF. If you want to use ESP-IDF v3.3 use the esp-idf-v3.3 branch.

Step 1 - Setup ESP-IDF

Download and setup the ESP-IDF.

Step 2 - Get the lwIP library with NAT

Download the repository of the NAT lwIP library using the follwing command:

git clone https://github.com/martin-ger/esp-lwip.git

Note: It is important to clone the repository. If it is only downloaded it will be replaced by the orginal lwIP library during the build.

Step 3 - Replace original ESP-IDF lwIP library with NAT lwIP library

  1. Go to the folder where the ESP-IDF is installed.
  2. Rename or delete the esp-idf/component/lwip/lwip directory.
  3. Move the lwIP library with NAT repository folder from Step 2 to esp-idf/component/lwip/
  4. Rename the lwIP library with NAT repository folder from esp-lwip to lwip.

Step 4 - Build and flash the esp-idf-nat-example project

  1. Configure and set the option "Enable copy between Layer2 and Layer3 packets" in the ESP-IDF project configuration.
    1. In the project directory run make menuconfig (or idf.py menuconfig for cmake).
    2. Go to Component config -> LWIP and set "Enable copy between Layer2 and Layer3 packets" option.
    3. Go to Example configuration and set SSID and Password of both, the uplink STA interface and the SoftAP.
  2. Build the project and flash it to the ESP32.

A detailed instruction on how to build, configure and flash a ESP-IDF project can also be found the official ESP-IDF guide.

DNS

By Default the DNS-Server which is offerd to clients connecting to the ESP32 AP is set to 8.8.8.8. Replace the value of the MY_DNS_IP_ADDR with your desired DNS-Server IP address (in hex) if you want to use a different one.

esp-idf-nat-example's People

Contributors

jonask1337 avatar martin-ger avatar

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.