ESP8266 WiFi repeater with ESP-12F (NodeMCU V3) and Arduino IDE.

To turn an ESP12E or ESP12F on a NodeMCU V3 module into a WiFi repeater, follow these instructions:
(Ok, to be precise, this is more like a router. A repeater is strictly speaking a layer2 device, while this thing acts as on OSI layer 3)
1) Download the Arduino IDE as a ZIP file from .

2) Unpack the ZIP archive into some location, for example to the 
3) Download with commands:
cd c:\temp\arduino-1.6.12\hardware\
mkdir esp8266com
cd esp8266com
git clone esp8266
4) Download binary tools (you need Python 2.7):
cd esp8266/tools
5) Download Cygwin
6) Run downloaded Cygwin setup (setup-x86_64.exe), Select Root Install Directory (C:\cygwin64), Select Local Package Directory (C:\cygwin64\Downloads) and install make util from Devel list: 

7) Complete Cygwin setup.
8) Edit files:
a) Check, that file c:\temp\arduino-1.6.12\hardware\esp8266com\arduino\tools\sdk\lwip\include\lwip\app\dhcpserver.h in the top contains 
#define USE_DNS
b) Edit file c:\temp\arduino-1.6.12\hardware\esp8266com\arduino\tools\sdk\lwip\include\lwipopts.h - change 
#ifndef IP_FORWARD
#define IP_FORWARD                      0
to code 
#ifndef IP_FORWARD
#define IP_FORWARD                      1
c) Edit file c:\temp\arduino-1.6.12\hardware\esp8266com\arduino\tools\sdk\lwip\include\lwip\opt.h - change 
#ifndef IP_FORWARD
#define IP_FORWARD                      0
to code 
#ifndef IP_FORWARD
#define IP_FORWARD                      1
d) Edit file c:\temp\arduino-1.6.12\hardware\esp8266com\arduino\tools\sdk\lwip\src\core\ipv4\ip.c - change  
 /* Do not forward packets onto the same network interface on which
   * they arrived. */
  if (netif == inp) {
    LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n"));
    goto return_noroute;
to code (comment)
/* Do not forward packets onto the same network interface on which
   * they arrived. */
  //if (netif == inp) {
  //  LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n"));
  //  goto return_noroute;
9) Open c:\temp\arduino-1.6.12\hardware\esp8266com\arduino\tools\sdk\lib\ and remove all liblwip*.a files.
10) Open Cygwin Console and run commands
cd c:/temp/arduino-1.6.12/hardware/esp8266com/arduino/tools/sdk/lwip/src/
make clean
make all
make install
make release

11) In the c:\temp\arduino-1.6.12\hardware\esp8266com\arduino\tools\sdk\lib\ will be 2 new files - liblwip_src.a and liblwip_gcc.a. Remove liblwip_src.a .
12) Open Arduino Ide, configure it for ESP-12E (NodeMCU 1.0)
13) Set up CPU frequency to 160MHz
14) Configure your WiFi router - add a route to the subnet to your default gateway (i.e. usually  your WiFi dsl/cable router)

15) Compile and Upload this code to the ESP-12F:
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>

/* Set these to your desired credentials for ESP8266 AP. */
const char *ssid = "ESPap";
const char *password = "thereisnospoon";
IPAddress apIP(192, 168, 4, 1);

// Setup credentials for original WiFi, that we plan to repeat
const char* ssidExt = "MyOrigWiFi";
const char* passwordExt = "MyOrigWiFiPass";

byte DNS_PORT = 53;

// A UDP instance to let us send and receive packets over UDP
WiFiUDP Udp;
byte packetBuffer[512]; //buffer to hold incoming and outgoing packets

WiFiUDP Udp8;

// Update these with values suitable for your network.
IPAddress ip(192, 168, 0, 13); //Node static IP
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);

void setup()


  WiFi.begin(ssidExt, passwordExt);
  WiFi.config(ip, gateway, subnet);

  //Wifi connection
  while (WiFi.status() != WL_CONNECTED) {

  Serial.print("Connected to ");
  Serial.print("IP address: ");
  Serial.print("dnsIP address: ");
  Serial.print("gatewayIP address: ");
  Serial.print("subnetMask address: ");

  Serial.println("Configuring access point...");
  /* You can remove the password parameter if you want the AP to be open. */
  //WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP(ssid, password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");


void loop()

  int noBytes = Udp.parsePacket();
  if ( noBytes ) {
    //    Serial.print(millis() / 1000);
    //    Serial.print(":Packet of ");
    //    Serial.print(noBytes);
    //    Serial.print(" received from ");
    //    Serial.print(Udp.remoteIP());
    //    Serial.print(":");
    //    Serial.println(Udp.remotePort());
    // We've received a packet, read the data from it, noBytes); // read the packet into the buffer

    // display the packet contents in HEX
    //    for (int i = 1; i <= noBytes; i++) {
    //      Serial.print(packetBuffer[i - 1], HEX);
    //      if (i % 32 == 0) {
    //        Serial.println();
    //      }
    //      else Serial.print(' ');
    //    } // end for
    //    Serial.println();

    IPAddress ip8(8, 8, 8, 8);
    Udp8.beginPacket(ip8, DNS_PORT); //NTP requests are to port 123
    Udp8.write(packetBuffer, noBytes);

    int cb = Udp8.parsePacket();
    if (!cb) {
     // Serial.println("no packet yet");
    else {
      //      Serial.print("packet received, length=");
      //      Serial.println(cb);
      byte packetBuffer8[cb];, cb);
      Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
      Udp.write(packetBuffer8, cb);

  } // end if
16) Open console monitor in Arduino IDE and restart your NodeMCU module.
17) Connect your PC to WiFi network, named ESPap .
18) Try to ping some site from your PC. If it pings well, you can try to open some site from your PCs browser.