title: Setup Routing between AP and STA in WIFI_AP_STA
body: <p>I am trying to setup routing or some interface between between AP and STA of the ESP8266 in my nodeMCU. I am trying to Setup a Wifi Repeater in NAT mode.   Here is the code I have written,</p>
  
  <pre><code>  #include &lt;ESP8266WiFi.h&gt;
    #include &lt;ESP8266mDNS.h&gt;
    const char* ssid = "********";
    const char* password = "********";
  
    /* Settings for SSID to be forwarded*/
  
    IPAddress staticIP(192,168,1,113);
    IPAddress gateway(192,168,1,1);
    IPAddress subnet(255,255,255,0);
  
    MDNSResponder mdns;
    WiFiServer server(80);
  
  
    int i=0;
  
    void setup(void)
    {
      Serial.begin(115200);
      Serial.println();
      WiFi.mode(WIFI_AP_STA);
      /*Station Mode Configuration*/
      Serial.printf("Connecting to %s\n", ssid);
      WiFi.begin(ssid, password);
      WiFi.config(staticIP, gateway, subnet);
      while (WiFi.status() != WL_CONNECTED)
      {
        delay(500);
        Serial.print(".");
      }
      Serial.println();
      Serial.print("Connected, IP address: ");
      Serial.println(WiFi.localIP());
      Serial.print("MAC Address: ");
      Serial.println(WiFi.macAddress());
      Serial.print("Gateway IP: ");
      Serial.println(WiFi.gatewayIP());
      Serial.print("DNS Server: ");
      Serial.println(WiFi.dnsIP());
  
      /*SoftAP configuration */
  
      //Serial.print("Setting soft-AP configuration ... ");
      //Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");
      Serial.println();
      Serial.println("!!!!!!!!!!!!!!!!!!!!!");
      Serial.println();
      Serial.print("Setting soft-AP ... ");
      Serial.println(WiFi.softAP("ESPsoftAP_01") ? "Ready" : "Failed!");
  
      Serial.print("Soft-AP IP address = ");
      Serial.println(WiFi.softAPIP());
    }
  
    void loop()
    {
      int j = WiFi.softAPgetStationNum();
      if(j != i)
      {
        Serial.printf("Stations connected to soft-AP = %d\n", WiFi.softAPgetStationNum());
        i = j;
      }
  
  
  /* Checks for the requests from the ESP clients and prints them on the serial monitor. */
      mdns.update();   // Check for any mDNS queries and send responses
  
      WiFiClient client = server.available();  // Check if a client has connected
      if (client)
      {
        Serial.println("");
      Serial.println("New client");
      Serial.println("Checkpoint 0");
  
      // Wait for data from client to become available
      while (client.connected() &amp;&amp; !client.available())
      {
        delay(1);
      }
      Serial.println("Checkpoint 1");
      // Read the first line of HTTP request
      String req = client.readStringUntil('\r');
      Serial.println(req);
      }
    }
  </code></pre>
  
  <p>I am able to connect ESP to my Wifi and also able to connect some stations to the ESP. But Unfortunately, I am having no luck transferring the request and response between the Clients of ESP and the Internet. </p>
  
  <p><strong>The Problem:</strong> In the last section, <code>checkpoint 0</code> is not getting printed which means clients is returning false. But according to this part </p>
  
  <pre><code>    int j = WiFi.softAPgetStationNum();
      if(j != i)
      {
        Serial.printf("Stations connected to soft-AP = %d\n", WiFi.softAPgetStationNum());
        i = j;
      }
  </code></pre>
  
  <p>Client is getting connected. Why is it so?</p>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code> Connecting to ********
   .......
   Connected, IP address: 192.168.1.113
   MAC Address: **:**:**:**:**:**
   Gateway IP: 192.168.1.1
   DNS Server: 0.0.0.0
  
   !!!!!!!!!!!!!!!!!!!!!
  
   Setting soft-AP ... Ready
   Soft-AP IP address = 192.168.4.1
   Stations connected to soft-AP = 1
  </code></pre>