espressif / ESP8266_RTOS_SDK

Latest ESP8266 SDK based on FreeRTOS, esp-idf style.
http://bbs.espressif.com
Apache License 2.0
3.33k stars 1.57k forks source link

如何使用ESP8266 LWIP中的NAT功能实现WiFi中继呢?? (GIT8266O-529) #952

Open git-binbin opened 4 years ago

git-binbin commented 4 years ago

如何使用ESP8266 LWIP中的NAT功能实现WiFi中继呢??

vinhjaxt commented 4 years ago

Follow to: https://github.com/martin-ger/esp32_nat_router

make menuconfig
--> Component config --> LWIP:
[*] Enable copy between Layer2 and Layer3 packets
[*] Enable IP forwarding
[*]   Enable NAT (new/experimental)

The code:

#include "lwip/opt.h"
#include "lwip/ip4_napt.h"
#include "tcpip_adapter.h"
#include "esp_netif.h"
#include "lwip/err.h"
#include "lwip/sys.h"

    esp_netif_init();
    u32_t napt_netif_ip = 0xC0A80401; // Set to ip address of softAP netif (Default is 192.168.4.1)
    ip_napt_enable(htonl(napt_netif_ip), 1);

But not work yet. Packet went out, and never come in :(

vinhjaxt commented 4 years ago

Local LAN still works :/