Inital config and Readme

This commit is contained in:
Martin Gergeleit
2026-04-23 22:37:37 +02:00
parent 787efb35f2
commit e95b2ff8c8
7 changed files with 82 additions and 14 deletions
+57 -2
View File
@@ -1,5 +1,7 @@
# esp_wifi_repeater
A full functional WiFi repeater (correctly: a WiFi NAT router)
A full functional WiFi NAT router (and now also a WiFi repeater aka. L2 bridge)
**NEW 2026:** *10 years after the first release it has finally become, what it ever pretendend to be: a true WiFi repeater. In order not to break any existing docs and links, the standard edition still remains the well-known NAT router version with all the advanced features. But if you are interested in a stripped down true L2 bridge, look below in the "WiFi Repeater - L2 bridge" section*
This is an implementation of a WiFi NAT router on the esp8266 and esp8285. It also includes support for a packet filtering firewall with ACLs, port mapping, traffic shaping, hooks for remote monitoring (or packet sniffing), an MQTT management interface, simple GPIO interaction, and power management. For a setup with multiple routers in a mesh to cover a larger area a new mode "Automesh" has been included https://github.com/martin-ger/esp_wifi_repeater#automesh-mode .
@@ -399,6 +401,51 @@ You can send the ESP to sleep manually once by using the "sleep" command.
Caution: If you save a _vmin_ value higher than the max supply voltage to flash, the repeater will immediately shutdown every time after reboot. Then you have to wipe out the whole config by flashing blank.bin (or any other file) to 0x0c000.
# WiFi Repeater - L2 Bridge
The project now offers two distinct operational modes: **NAT Router** and **Layer 2 Bridge** (referred to as "Repeater mode"). While both modes extend network coverage, they fundamentally differ in how they handle traffic and device identity.
### NAT Router Mode (Standard)
In this mode, as descibed above, the device acts as a standard gateway. It creates a new subnet and performs Network Address Translation (NAT) for all devices connected to its Access Point (AP).
* **Subnet Isolation**: Connected clients are on a private subnet (e.g., 192.168.4.x) and are shielded from the primary network.
* **Traffic Identity**: All traffic from clients appears to the main router as if it originates from the ESP8266's own IP/MAC address.
* **Simplicity**: Requires no special configuration on the upstream router and is compatible with virtually all standard Wi-Fi networks.
* **Limitation**: Devices on the primary network cannot easily initiate connections to devices behind the repeater because of the NAT barrier, unless you use port mapping.
### Layer 2 Bridge Mode ("Repeater" Variant)
This mode implements a transparent Layer 2 (Data Link Layer) bridge. The ESP8266 extends the existing primary network rather than creating a secondary subnet.
* **Transparent Bridging**: The ESP8266 bridges traffic at the Ethernet frame level. Connected clients receive IP addresses directly from the primary network's DHCP server (via DHCP snooping/relay).
* **Unified Network**: All devices (both on the repeater and the main router) exist on the same L2 broadcast domain.
* **Device Visibility**: Devices behind the repeater retain their original MAC and IP identities on the main network. This allows local discovery protocols (like mDNS/Bonjour, UPnP, or network discovery) to function seamlessly across the entire network.
* **Complexity**: Requires advanced handling, such as Proxy ARP and DHCP snooping, to ensure the upstream network correctly routes traffic back to the "hidden" clients connected through the repeater.
* **Use Case**: Ideal when device discovery (e.g., controlling a printer or smart home device via a phone app) across the entire network is required.
The repeater mode has less features: routing, port mapping and DHCP are not required, ACLs and Automesh also make no real sense and network monitoring via pcap as well. So all these features are not available in repeater mode. Also MQTT has been stripped. The remaining features are still available via the console or the remote console.
You can find the precompiled binaries in the folder "firmware-repeater".
First config of the repeater mode version is basically as simple as for the NAT router. Via the serial console simply set ssid, password, ap_ssid, and ap_password, then save and reset. If you want to do it via the web interface, it is also simple, but you have to obey the right order:
- Connect to the "MyAP" WiFi with your client
- Point the browser to "http://192.168.4.1"
- Enter **first** the AP Settings ssid and password first, set and restart
- Then connect to you newly defined AP ssid, point the browser again to "http://192.168.4.1"
- Now enter the STA settings ssid and password and connect
Once the STA ssid is defined, the repeater will no longer run its own DHCP server, but receives its IP from the upstream DHCP (no more 192.168.4.1). In order to connect to its web page, you then have to look up the assigned address either in your upstream router or at the serial console with "show stats". You can always reset the ESP via the console and "reset factory".
### Key Contrast Summary
| Feature | NAT Router | Layer 2 Bridge |
| :--- | :--- | :--- |
| **Network Architecture** | Creates new, isolated subnet | Extends existing broadcast domain |
| **IP Addressing** | Clients use secondary pool | Clients use upstream DHCP server |
| **Discovery (mDNS/UPnP)** | Often blocked/difficult | Fully supported (Transparent) |
| **Upstream Visibility** | Client identity hidden (NAT) | Client identity preserved |
| **Implementation** | Standard networking | Advanced proxying (Proxy ARP/Snooping) |
# Building and Flashing
If you have Docker installed, the easiest way to get access to the full build environment is to connect your ESP8266 to /dev/ttyUSB0 and run the image using:
```
@@ -409,6 +456,15 @@ make
make flash
```
To build the L2 WiFi Repeater version just use the VARIANT=bridge option for the make command:
```
git clone https://github.com/martin-ger/esp_wifi_repeater.git
docker run -it --rm --device=/dev/ttyUSB0 -v $(pwd)/esp_wifi_repeater:/home/esp/esp_wifi_repeater martinfger/iot_devel:1.0
cd esp_wifi_repeater
make VARIANT=bridge
make flash
```
To set up the build environment from scratch and build this binary download and install the esp-open-sdk (I suggest this version with base NONOS SDK 2.2: https://github.com/xxxajk/esp-open-sdk). Make sure, you can compile and download the included "blinky" example.
Then download this source tree in a separate directory and adjust the BUILD_AREA variable in the Makefile and any desired options in user/user_config.h. Changes of the default configuration can be made in user/config_flash.c. Build the esp_wifi_repeater firmware with "make". "make flash" flashes it onto an esp8266.
@@ -454,7 +510,6 @@ If configured correctly, the update will start and the ESP will reboot with the
# Known Issues
- Due to the limitations of the ESP's SoftAP implementation, there is a maximum of 8 simultaniously connected stations.
- The ESP8266 requires a good power supply as it produces current spikes of up to 170 mA during transmit (typical average consumption is around 70 mA when WiFi is on). Check the power supply first, if your ESP runs unstable and reboots from time to time. A large capacitor between Vdd and Gnd can help if you experience problems here.
- All firmware published after 17/Oct/2017 have been built with the patched version of the SDK 2.1.0 from Espressif that mitigates the KRACK (https://www.krackattacks.com/ ) attack.
# Licenses
The software is open source. Third party source files have their own license header. For all other files the MIT license applies.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
0eb12ac84f53f2f0c40829b2ab31818c0d70bc66 firmware/0x02000.bin
d5104f0605653e0e62ffb562522f56e69078c333 firmware/0x82000.bin
9bd7d25204d71b3db5f35e0b2def8a6aaa7f765c firmware/0x00000.bin
+5
View File
@@ -11,6 +11,9 @@
#include "osapi.h"
#include "user_interface.h"
#include "sys_time.h"
#include "config_flash.h"
extern sysconfig_t config;
/* my_channel is set by wifi event handler in user_main.c on STAMODE_CONNECTED */
extern uint8_t my_channel;
@@ -376,6 +379,8 @@ static err_t ICACHE_FLASH_ATTR bridge_output_ap(struct netif *netif, struct pbuf
static err_t ICACHE_FLASH_ATTR bridge_input_ap(struct pbuf *p, struct netif *inp)
{
if (os_strcmp(config.ssid, WIFI_SSID) == 0) return s_orig_input_ap(p, inp);
struct pbuf *q = pbuf_alloc(PBUF_RAW, p->tot_len + 16, PBUF_RAM);
Bytes_out += p->tot_len;
+16 -11
View File
@@ -3367,8 +3367,13 @@ static void ICACHE_FLASH_ATTR tcp_client_connected_cb(void *arg)
ringbuf_reset(console_rx_buffer);
ringbuf_reset(console_tx_buffer);
char send_data[] = "Welcome to WiFi Repeater " ESP_REPEATER_VERSION "\r\n"
"Enter 'help' to get help.\r\nCMD>";
char send_data[] = "Welcome to "
#ifdef REPEATER_MODE
"WiFi Repeater "
#else
"WiFi NAT Router "
#endif
ESP_REPEATER_VERSION "\r\nEnter 'help' to get help.\r\nCMD>";
espconn_send(pespconn, (uint8_t *) send_data, os_strlen(send_data));
#if ACLS
deny_cb_conn = pespconn;
@@ -3555,10 +3560,15 @@ static void ICACHE_FLASH_ATTR web_config_client_connected_cb(void *arg)
if (page_buf == NULL)
return;
os_sprintf(page_buf, config_page, config.ssid, config.password,
#ifndef REPEATER_MODE
config.automesh_mode != AUTOMESH_OFF ? "checked" : "",
#endif
config.ap_ssid, config.ap_password,
config.ap_open ? " selected" : "", config.ap_open ? "" : " selected",
IP2STR(&config.network_addr));
config.ap_open ? " selected" : "", config.ap_open ? "" : " selected"
#ifndef REPEATER_MODE
, IP2STR(&config.network_addr)
#endif
);
os_free(config_page);
espconn_send(pespconn, page_buf, os_strlen(page_buf));
@@ -4081,7 +4091,7 @@ void ICACHE_FLASH_ATTR user_set_softap_ip_config(void)
wifi_softap_dhcps_stop();
#ifdef REPEATER_MODE
if (config.ssid[0] != 0) {
if (os_strcmp(config.ssid, WIFI_SSID) != 0) {
/* Bridge mode: Use a dummy subnet to avoid overlap with the bridged network.
The bridge logic will handle the actual data plane. */
IP4_ADDR(&info.ip, 172, 31, 255, 1);
@@ -4103,12 +4113,7 @@ void ICACHE_FLASH_ATTR user_set_softap_ip_config(void)
wifi_set_ip_info(nif->num, &info);
#ifdef REPEATER_MODE
if (config.ssid[0] != 0) {
/* wifi_set_ip_info can restart DHCP on some SDK versions; keep it off in bridge mode */
wifi_softap_dhcps_stop();
}
#endif
dhcp_lease.start_ip = config.network_addr;
ip4_addr4(&dhcp_lease.start_ip) = 2;
@@ -4118,7 +4123,7 @@ void ICACHE_FLASH_ATTR user_set_softap_ip_config(void)
wifi_softap_set_dhcps_lease_time(config.dhcps_lease_time); // in minutes
#ifdef REPEATER_MODE
if (config.ssid[0] == 0) {
if (os_strcmp(config.ssid, WIFI_SSID) == 0) {
wifi_softap_dhcps_start();
dhcps_set_DNS(&dns_ip);
}