logo elektroda
logo elektroda
X
logo elektroda

[Solved] AP mode in Wemos D1 mini and ESP8266: routing network traffic and manipulation of metrics

tos18 1209 8
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20802190
    tos18
    Level 42  
    The Wemos D1 mini and others based on the ESP8266 have AP (Access Point) mode which works very nicely but I have one problem.
    When a client computer connects to such an AP it treats it as a default gateway and tries to route all network traffic through it, no matter that we have other connections active (lan, lte, second wlan). As a result, it is impossible to use the internet after connecting to esp. Also it is not possible to correctly display a page set up on esp when it has links to external sources (e.g. jquery, bootstrap, etc)

    From what I can see the connection with esp has a metric of 3 while others have higher values (my current wifi connection has 20)

    Is there any solution ?

    I don't know if esp has the possibility to manipulate the metric.
  • ADVERTISEMENT
  • #2 20802761
    khoam
    Level 42  
    How is the gateway set up in SoftAP?
  • ADVERTISEMENT
  • #3 20802778
    tos18
    Level 42  
    yes:
    Code: Arduino
    Log in, to see the code


    or yes:
    Code: Arduino
    Log in, to see the code


    In both cases the same effect.
  • #4 20802784
    khoam
    Level 42  
    tos18 wrote:
    or yes:

    This is set to the edge router, instead of itself.
  • ADVERTISEMENT
  • #5 20802792
    tos18
    Level 42  
    I can't because I won't know the network address at the target location.
    That's why I use AP mode. If I had access to the network I would use STA mode and the problem would not exist.
  • #6 20802823
    khoam
    Level 42  
    So the issue is a bit complicated. Assuming that the ESP will ultimately be on the same IP subnet as the edge router, I would first run the ESP in client mode and thus find out the address of the edge router. Then I would shut down the client and switch to SoftAP mode and set the gateway accordingly. Of course, you wouldn't need to do this every time you restarted ESP, the gateway address could be stored in an emulated EEPROM or directly in SPIFFS.
  • ADVERTISEMENT
  • #7 20802858
    tos18
    Level 42  
    If esp were to be on the same network then I would use STA mode, DHCP would assign an address and specify the gateway - no problem in STA mode.
    There is also no problem if the connection to esp has a metric further (read larger) than the internet connection being used.
    Then the connections work correctly and all traffic is directed to the default gateway and queries for esp go to the network created by esp.
  • Helpful post
    #8 20802919
    khoam
    Level 42  
    Then try setting 0.0.0.0 as a gateway in ESP. According to the standard:
    "0.0.0.0 has the specific meaning "unspecified". This roughly translates to "there is none" in the context of a gateway"
    I have not checked.
  • #9 20802956
    tos18
    Level 42  
    Code: Arduino
    Log in, to see the code

    Helped.
    Metrics something around 300 and no registered gate.

    Thanks again.

Topic summary

The discussion revolves around the challenges faced when using the Wemos D1 mini and ESP8266 in Access Point (AP) mode, particularly regarding network traffic routing. When a client connects to the ESP's AP, it defaults to using the ESP as the gateway, disrupting internet access through other connections. Users explore potential solutions, including configuring the ESP's gateway settings. Suggestions include setting the gateway to 0.0.0.0 to prevent it from being treated as a default gateway, which successfully resolved the issue for one user. The conversation also touches on the importance of network metrics and the implications of using different modes (AP vs. STA) based on network access.
Summary generated by the language model.
ADVERTISEMENT