esp32_nat_router icon indicating copy to clipboard operation
esp32_nat_router copied to clipboard

Failed more than 2 NAT Router.

Open beyonlo opened this issue 5 years ago • 8 comments

Hi, I created 3 ESP32 NAT router and not works, just max 2.

This not works: SmartPhone --> ESP32-NAT-03 --> ESP32-NAT-02 --> ESP32-NAT-01 --> REAL-WIFI-ROUTER --> INTERNET Problem: SmartPhone connect to ESP32-NAT-03 but internet NOT WORKS. Just change SmartPhone to connect to ESP32-NAT-02 and everything works. If I change order between 03 and 02, so 02 not works anymore, like this: ESP32-NAT-02 --> ESP32-NAT-03 --> ESP32-NAT-01 So I think there are a limitation about more than 2 NAT nodes, is it correct?

This works fine: SmartPhone --> ESP32-NAT-02 --> ESP32-NAT-01 --> REAL-WIFI-ROUTER --> INTERNET

Any ideia?

Thanks

beyonlo avatar Mar 23 '20 13:03 beyonlo

any idea?

beyonlo avatar Apr 22 '20 20:04 beyonlo

Change the IP addresses so that they are different on the ESP.

cloudykeyru avatar May 28 '20 10:05 cloudykeyru

In wifi_init function, change the following line to different IP address for every devices:

    IP4_ADDR(&ipInfo.ip, 192,168,4,1); // change this IP
    IP4_ADDR(&ipInfo.gw, 192,168,4,1); // change this IP
    IP4_ADDR(&ipInfo.netmask, 255,255,255,0);

In app_main function, change the following line to different IP address for every devices:

#if IP_NAPT
    u32_t napt_netif_ip = 0xC0A80401; // Set to ip address of softAP netif (Default is 192.168.4.1) (change this IP using hex representation)
    ip_napt_enable(htonl(napt_netif_ip), 1);
    ESP_LOGI(TAG, "NAT is enabled");
#endif

I've tried it using four different devices with IP addresses 192.168.1.1, 192.168.2.1, 192.168.3.1, 192.168.4.1, respectively and its working.

marfanwicaksono avatar Sep 24 '20 04:09 marfanwicaksono

I've tried it using four different devices with IP addresses 192.168.1.1, 192.168.2.1, 192.168.3.1, 192.168.4.1, respectively and its working.

@marfanwicaksono

Great solution. Problem with that is to need to generate many fimrwares, I mean, one firmware for each IP address that I want. Maybe a better solution is to have on the web interface a place to user choose the IP for each device (AP).

Thanks.

beyonlo avatar Sep 24 '20 11:09 beyonlo

via:

  • web interface + GPIO to reset to factory defaults
  • and/or GPIO jumper selecting IP out of two or four predefined IPs
  • and/or serial port command to set IP

beta-tester avatar Feb 16 '21 07:02 beta-tester

Is there away to add custom mac address to wifiSTA.

Like in wifi_init: IP4_ADDR(&ipInfo.mac, 0x50, 0xBC, 0x96, 0xAE, 0x00, 0xCE);

ArhiLeeve avatar Feb 19 '21 13:02 ArhiLeeve

@ArhiLeeve maybe you can add a method in the main entrypoint to customize the base mac just when ESP32 boots. see

  • https://github.com/espressif/esp-idf/blob/master/docs/en/api-reference/system/system.rst#base-mac-address
  • https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system.html#base-mac-address

this woiuld be maybe the easiest way, without looking for the point where you can kick in to change the wifiSTA.mac.

beta-tester avatar Feb 22 '21 06:02 beta-tester

@ArhiLeeve yes, there is a function for this in esp_wifi component esp_wifi_set_mac()

risinek avatar Apr 10 '21 10:04 risinek