Wiznet makers

scott

Published May 15, 2026 ©

123 UCC

20 WCC

45 VAR

0 Contests

0 Followers

0 Following

Original Link

ESP32 NAT Router

Building an ESP32 Ethernet Router with W5500 — WiFi Uplink, Wired LAN Downlink

COMPONENTS Hardware components

WIZnet - W5500

x 1


PROJECT DESCRIPTION

요약

ESP32 NAT 라우터는 ESP32 마이크로컨트롤러를 소프트웨어 기반 WiFi 라우터로 동작시키는 오픈소스 펌웨어입니다. 스핀오프 프로젝트인 ESP32 Ethernet Router에서는 W5500 SPI 이더넷 모듈이 유선 LAN 다운링크를 담당하며, WiFi 업링크로 받은 인터넷을 유선 기기에 분배합니다. NAT, 방화벽(ACL), WireGuard VPN, PCAP 패킷 캡처까지 탑재한 이 조합은 $5 내외 부품으로 구성 가능한 풀스택 네트워크 게이트웨이입니다.


개요

소규모 홈랩이나 IoT 환경에서는 흔히 이런 상황이 생깁니다. WiFi는 있지만 유선 포트가 부족하고, 게스트 기기나 IoT 디바이스를 메인 네트워크와 격리하고 싶지만 별도 라우터를 구매하기엔 과합니다. VPN 게이트웨이가 필요하지만 상용 공유기의 커스터마이징 한계에 막힙니다.

ESP32 NAT 라우터 프로젝트는 이 문제를 ESP32 하나로 해결합니다. WiFi STA 인터페이스로 기존 네트워크에 클라이언트로 접속하고, 다운링크로 유선 이더넷이나 별도 WiFi AP를 제공합니다. 오픈소스 펌웨어이므로 방화벽 규칙, DHCP 예약, VPN 설정까지 자유롭게 제어할 수 있습니다.


프로젝트 생태계

이 펌웨어는 martin-ger/esp32_nat_router를 기원으로 여러 방향으로 진화했습니다. linmudaye/ESP32는 그 포크(fork) 중 하나로, 원본의 기능을 그대로 계승합니다. 생태계 전체를 이해하면 W5500이 어느 지점에서 등장하는지 명확해집니다.

프로젝트업링크(인터넷)다운링크(LAN)Ethernet 칩
esp32_nat_routerWiFi APWiFi STA
esp32_nat_router (ETH 변형)EthernetWiFi APLAN8720 (WT32-ETH01)
esp32_ethernet_routerWiFi STAEthernetLAN8720 또는 W5500
esp32_eth_wifi_bridgeEthernetWiFi APLAN8720

W5500이 실제로 적용된 것은 esp32_ethernet_router입니다. WiFi를 업링크로, 유선 이더넷을 다운링크로 사용하는 방향이 역전된 변형이며, Ethernet PHY가 내장되지 않은 ESP32-C3와 W5500 SPI 모듈을 조합해 구현합니다.


시스템 아키텍처

데이터 흐름은 단순합니다. WiFi STA로 수신한 인터넷 트래픽이 ESP32-C3 내부의 lwIP 스택에서 NAT 처리된 후, SPI를 통해 W5500으로 전달되어 유선 이더넷 포트로 나갑니다. 반대 방향도 동일합니다. 중요한 점은, W5500은 Ethernet 프레임의 송수신만 담당하며 NAT·DHCP·라우팅 연산은 전부 ESP32-C3의 lwIP가 처리한다는 것입니다.


기술 특징

이 펌웨어가 단순 WiFi 중계기와 다른 이유는 네트워크 장비 수준의 기능을 단일 MCU 위에 구현한 데 있습니다.

  • NAT/IP Forwarding: 최대 5~15 Mbps 처리량(ESP32 기준), 유선 클라이언트는 설정 없이 인터넷 접속 가능
  • WireGuard VPN: 업링크 트래픽 전체를 VPN 터널로 보호, Kill Switch 지원(터널 다운 시 평문 트래픽 차단)
  • ACL 방화벽: 4방향(to_esp / from_esp / from_eth / to_eth) × 최대 16개 규칙, 프로토콜·CIDR·포트 기반 필터링
  • PCAP 패킷 캡처: Ethernet 인터페이스 트래픽을 TCP 포트 19000으로 스트리밍, Wireshark 직접 연결 가능
  • DHCP 예약: MAC 주소 기반 고정 IP 할당, 최대 16개
  • 포트 포워딩: TCP/UDP 외부 포트를 내부 호스트로 매핑
  • WPA2-Enterprise 지원: PEAP/TTLS/TLS 인증 업링크 연결
  • OTA 업데이트: Web UI를 통한 원격 펌웨어 플래싱
  • Web UI / 시리얼 CLI / 원격 콘솔(TCP): 세 가지 설정 인터페이스

기능이 많을수록 RAM 소비도 늘어납니다. VPN + PCAP + ACL을 동시 활성화하면 힙 고갈 위험이 있으므로, 사용하지 않는 기능은 비활성화하는 것이 성능 유지의 핵심입니다.


W5500이 담당하는 역할

ESP-IDF 드라이버 연동 구조

ESP-IDF는 esp_eth 드라이버 레이어를 통해 W5500을 표준 Ethernet 인터페이스로 등록합니다. 애플리케이션 코드 관점에서는 W5500이 일반 Ethernet 포트와 동일하게 보입니다. lwIP 스택이 이 인터페이스 위에서 IP 패킷을 처리하므로, W5500 자체의 내장 TCP/IP 기능은 이 프로젝트에서 사용되지 않습니다.

핀 구성 (ESP32-C3 SuperMini 기준)

W5500 핀ESP32-C3 GPIO기능
GNDGND그라운드
3.3V / VCC외부 전원전원 (주의: 내장 레귤레이터 불가)
MISOGPIO 5SPI 데이터 입력
MOSIGPIO 6SPI 데이터 출력
SCLKGPIO 4SPI 클럭
SCS (CS)GPIO 7SPI 칩 셀렉트
INTGPIO 3인터럽트
RSTGPIO 2하드웨어 리셋

주요 운용 포인트

  • SPI 클럭: 기본 25 MHz, 배선이 짧고 깨끗하면 최대 40 MHz까지 상향 가능. CLI set_spi_clock <MHz> 명령으로 런타임 조정
  • 전원: W5500은 최대 250 mA를 소비하므로 ESP32-C3 SuperMini의 내장 3.3V 레귤레이터로는 부족합니다. 외부 전원 공급 필수
  • MAC 주소: W5500에 내장 MAC이 없으므로 펌웨어가 ESP32-C3의 Base MAC에서 자동 파생하여 할당
  • SPI 오류 모니터링: show status 명령으로 SPI 오류 카운터 확인 가능

WT32-ETH01(LAN8720) vs W5500 + ESP32-C3

항목WT32-ETH01 (LAN8720)W5500 + ESP32-C3
CPUESP32 듀얼코어 240 MHzESP32-C3 싱글코어 160 MHz
Ethernet 인터페이스RMII (보드 내장)SPI
처리량(실측)~15 Mbps~4 Mbps (다운) / ~1 Mbps (업)
폼팩터통합 모듈MCU + 별도 모듈 조합
전원 구성USB 단일W5500 외부 전원 별도
적합 용도범용 라우터/게이트웨이저전력 IoT 라우터

비즈니스 가치

ESP32 + W5500 조합이 주목받는 이유는 부품 단가 대비 기능 밀도에 있습니다. 시중의 소형 공유기와 달리 모든 설정이 오픈소스로 공개되어 있고, 사용 목적에 맞게 기능을 활성화하거나 제거할 수 있습니다. W5500은 이 유연성을 유선 이더넷 환경으로 확장하는 열쇠가 됩니다.

실제 적용 가능한 시나리오는 다음과 같습니다.

  • 홈랩 게이트웨이: WiFi만 있는 환경에서 서버·NAS·스위치 등 유선 기기에 인터넷 제공. DHCP 예약과 포트 포워딩으로 서버 외부 노출 제어
  • IoT 격리망: 스마트홈 기기를 별도 유선 세그먼트로 격리하고, ACL로 메인 네트워크 접근 차단. PCAP 기능으로 IoT 트래픽 실시간 분석 가능
  • WireGuard VPN 게이트웨이: 유선 LAN 전체 트래픽을 VPN으로 보호. Kill Switch 활성화 시 VPN 중단 시 평문 유출 원천 차단
  • 기업망 브리지: WPA2-Enterprise(802.1X) 환경에 WPA2-PSK 기기를 접속시켜야 하는 상황에서 인증 변환 레이어로 활용

WIZnet 관점에서 이 프로젝트는 W5500의 범용 SPI Ethernet NIC 포지셔닝을 잘 보여주는 사례입니다. Ethernet PHY가 내장되지 않은 저가 MCU에 SPI로 연결하여 유선 인터페이스를 추가하는 패턴은 산업용 게이트웨이, 원격 모니터링 장비, 엣지 컴퓨팅 노드 등 다양한 제품 설계에 직접 응용할 수 있습니다.


한계 및 개선 방향

ESP32 + W5500 조합은 IoT 규모의 라우팅 요구에 잘 맞지만, 구조적 특성에서 오는 한계도 분명합니다.

현재 한계

  • 처리량 상한: W5500 + ESP32-C3 조합의 실측 처리량은 다운스트림 약 4 Mbps / 업스트림 약 1 Mbps 수준으로, 다중 동시 스트리밍이나 대용량 파일 전송 환경에는 적합하지 않습니다
  • 동시 클라이언트 제한: RAM 의존적 구조로 최대 5대(ESP32-C3 기준) 동시 접속 제한
  • 소프트웨어 네트워크 스택: NAT, DHCP, ACL, WireGuard를 모두 단일 MCU에서 처리하여 기능이 중첩될수록 CPU/RAM 부하 증가
  • 외부 전원 필요: W5500의 전류 소비로 인해 USB 단일 전원 구성이 불가하며, 실제 배포 시 전원 설계가 추가됩니다

개선 방향

  • 듀얼코어 ESP32 + W5500: ESP32-C3 대신 ESP32(듀얼코어 240 MHz)와 W5500을 조합하면 처리량과 동시 클라이언트 수를 동시에 개선할 수 있습니다. SPI 연결 방식은 동일하므로 드라이버 수정 없이 적용 가능합니다
  • W6100 활용: 향후 IPv6 지원이 요구되는 환경에서는 W6100(IPv4/IPv6 Dual Stack)으로 교체하면 IPv6 라우팅까지 대응 가능합니다
  • 하드웨어 TCP/IP 오프로딩 활용 시나리오: 현재 구조에서는 W5500의 하드웨어 TCP/IP 기능을 사용하지 않지만, 단순 TCP 세션 기반 데이터 수집·전송이 목적인 엣지 디바이스라면 W5500 하드웨어 소켓을 직접 활용해 MCU 부하를 줄이는 방향도 고려할 수 있습니다

FAQ

Q. ESP32-C3 SuperMini 보드만 있으면 바로 시작할 수 있나요? W5500 SPI 이더넷 모듈을 별도로 준비해야 합니다. 또한 W5500은 최대 250 mA를 소비하므로 ESP32-C3의 내장 3.3V 레귤레이터로는 부족합니다. 외부 3.3V 전원이나 별도 레귤레이터를 함께 구성해야 안정적으로 동작합니다.

Q. 처리량 4 Mbps로 일반 인터넷 사용이 가능한가요? 넷플릭스 등 단일 HD 스트리밍(4~8 Mbps)은 경계선 수준이며, 일반 웹 브라우징·IoT 통신·소규모 파일 전송에는 충분합니다. 다중 동시 스트리밍이나 대용량 전송 환경에는 WT32-ETH01(LAN8720 기반, ~15 Mbps)이 더 적합합니다.

Q. WireGuard VPN을 켜면 성능이 많이 떨어지나요? VPN 암복호화 연산이 추가되므로 처리량이 추가로 감소합니다. ESP32-C3는 싱글코어이므로 VPN 활성화 시 ACL·PCAP 캡처를 동시에 사용하는 것은 권장하지 않습니다. 필요한 기능만 선택적으로 활성화하는 것이 성능 유지의 핵심입니다.

Q. 기업 WPA2-Enterprise 네트워크에도 연결할 수 있나요? PEAP, TTLS, TLS 방식의 WPA2-Enterprise 업링크를 지원합니다. 기업망에 연결한 뒤 하단 유선 기기에는 WPA2-PSK 또는 설정 없이 DHCP 자동 할당으로 인터넷을 제공합니다.

Q. 펌웨어 업데이트는 어떻게 하나요? Web UI의 Device Management 섹션에서 OTA(Over-the-Air) 업데이트를 지원합니다. 브라우저에서 바이너리를 업로드하면 자동으로 플래시됩니다. 업데이트 실패 시 파티션 롤백 기능으로 이전 버전으로 자동 복원됩니다.



Summary

The ESP32 NAT Router is an open-source firmware that turns an ESP32 microcontroller into a software-based WiFi router. In its spin-off project, ESP32 Ethernet Router, a W5500 SPI Ethernet module handles the wired LAN downlink — distributing internet received over a WiFi uplink to wired devices. With NAT, ACL firewall, WireGuard VPN, and PCAP packet capture all on board, this combination delivers a full-stack network gateway built from roughly $5 worth of components.


Overview

A common problem in home labs and IoT environments: WiFi is available, but wired ports are scarce. You want to isolate guest devices or IoT hardware from your main network, but buying a dedicated router feels like overkill. You need a VPN gateway, but commercial routers won't let you customize the firmware.

The ESP32 NAT Router project solves this with a single ESP32. It connects to an existing network as a WiFi STA client and provides internet to downstream devices through a wired Ethernet port or a secondary WiFi AP. Because the firmware is fully open-source, you control everything — firewall rules, DHCP reservations, VPN configuration, and more.


Project Ecosystem

This firmware traces back to martin-ger/esp32_nat_router and has since branched into several directions. linmudaye/ESP32 is one such fork, carrying forward the full feature set of the original. Understanding the ecosystem makes it clear exactly where W5500 enters the picture.

ProjectUplink (Internet)Downlink (LAN)Ethernet Chip
esp32_nat_routerWiFi APWiFi STA
esp32_nat_router (ETH variant)EthernetWiFi APLAN8720 (WT32-ETH01)
esp32_ethernet_routerWiFi STAEthernetLAN8720 or W5500
esp32_eth_wifi_bridgeEthernetWiFi APLAN8720

W5500 appears in esp32_ethernet_router — a direction-reversed variant that uses WiFi as the uplink and wired Ethernet as the downlink. It pairs an ESP32-C3 (which has no built-in Ethernet PHY) with a W5500 SPI module to add the wired interface.


Architecture

The data flow is straightforward. Internet traffic received over the WiFi STA interface is processed by the lwIP stack inside the ESP32-C3 — NAT, routing, and all — then passed through SPI to the W5500, which transmits it over the wired Ethernet port. The reverse path works the same way. The key point: W5500 handles only Ethernet frame transmission and reception. NAT, DHCP, and all routing logic run entirely on the ESP32-C3's lwIP stack.


Technical Highlights

What separates this firmware from a simple WiFi repeater is the depth of network functionality it brings to a single MCU.

  • NAT / IP Forwarding: Up to 5–15 Mbps throughput (ESP32); wired clients get internet access with zero configuration
  • WireGuard VPN: Full tunnel for all upstream traffic; Kill Switch blocks plaintext traffic when the tunnel is down
  • ACL Firewall: 4-directional rule sets (to_esp / from_esp / from_eth / to_eth) × 16 rules each; filtering by protocol, CIDR, and port
  • PCAP Packet Capture: Streams Ethernet interface traffic over TCP port 19000 directly into Wireshark
  • DHCP Reservations: MAC-to-IP static assignments, up to 16 entries
  • Port Forwarding: Maps external TCP/UDP ports to internal hosts
  • WPA2-Enterprise Support: Connects upstream via PEAP, TTLS, or TLS authentication
  • OTA Updates: Remote firmware flashing through the Web UI
  • Web UI / Serial CLI / Remote Console (TCP): Three configuration interfaces

The more features you enable, the more RAM each one consumes. Running VPN, PCAP, and ACL simultaneously risks heap exhaustion. Disabling unused features is the single most effective way to preserve performance.


Where W5500 Fits

Driver Integration with ESP-IDF

ESP-IDF registers W5500 as a standard Ethernet interface through the esp_eth driver layer. From the application's perspective, W5500 looks identical to any other Ethernet port. The lwIP stack handles IP packets over this interface, which means W5500's built-in hardware TCP/IP engine is not used in this project — W5500 operates purely as a MAC/PHY layer device.

Pin Assignment (ESP32-C3 SuperMini)

W5500 PinESP32-C3 GPIOFunction
GNDGNDGround
3.3V / VCCExternal supplyPower (onboard regulator insufficient)
MISOGPIO 5SPI Data In
MOSIGPIO 6SPI Data Out
SCLKGPIO 4SPI Clock
SCS (CS)GPIO 7SPI Chip Select
INTGPIO 3Interrupt
RSTGPIO 2Hardware Reset

Key Operating Notes

  • SPI Clock: Default 25 MHz; can be raised to 40 MHz with short, clean wiring. Adjust at runtime with the CLI command set_spi_clock <MHz>
  • Power Supply: W5500 draws up to 250 mA — beyond the rating of the ESP32-C3 SuperMini's onboard 3.3V regulator. An external power supply is required
  • MAC Address: W5500 has no factory MAC address. The firmware automatically derives one from the ESP32-C3's base MAC
  • SPI Error Monitoring: Use show status to check SPI error counters and diagnose wiring issues

WT32-ETH01 (LAN8720) vs W5500 + ESP32-C3

ParameterWT32-ETH01 (LAN8720)W5500 + ESP32-C3
CPUESP32 dual-core 240 MHzESP32-C3 single-core 160 MHz
Ethernet InterfaceRMII (onboard)SPI
Throughput (measured)~15 Mbps~4 Mbps down / ~1 Mbps up
Form FactorIntegrated moduleMCU + separate module
Power SetupSingle USBExternal supply for W5500
Best FitGeneral-purpose router/gatewayLow-power IoT router

Business Value

The ESP32 + W5500 combination stands out for its feature density relative to component cost. Unlike commercial small routers, every setting is open-source and adjustable — features can be added or stripped depending on the use case. W5500 extends that flexibility into wired Ethernet environments.

Practical deployment scenarios include:

  • Home Lab Gateway: Provides wired internet to servers, NAS, and switches in WiFi-only environments. DHCP reservations and port forwarding give precise control over external access
  • IoT Isolated Network: Segments smart home devices onto a dedicated wired subnet, with ACL rules blocking access to the main network. PCAP capture enables real-time traffic inspection without any client changes
  • WireGuard VPN Gateway: Protects all wired LAN traffic through a VPN tunnel. With Kill Switch enabled, plaintext traffic never leaks when the tunnel drops
  • WPA2-Enterprise Bridge: Lets simple devices connect to corporate 802.1X networks by handling authentication upstream and presenting WPA2-PSK or open access downstream

From WIZnet's perspective, this project is a strong demonstration of W5500 as a general-purpose SPI Ethernet NIC. The pattern of adding a wired interface to a low-cost MCU that lacks an integrated Ethernet PHY is directly applicable to industrial gateways, remote monitoring devices, and edge computing nodes.


Limitations and Future Improvements

The ESP32 + W5500 combination fits IoT-scale routing well, but its architecture comes with clear constraints.

Current Limitations

  • Throughput ceiling: The W5500 + ESP32-C3 combination delivers roughly 4 Mbps downstream / 1 Mbps upstream — adequate for IoT and light browsing, but not suited for multiple simultaneous video streams or bulk file transfers
  • Client limit: RAM-dependent architecture caps simultaneous connections at 5 clients on ESP32-C3
  • Software network stack: NAT, DHCP, ACL, and WireGuard all share a single MCU; stacking features increases CPU and RAM pressure
  • External power requirement: W5500's current draw makes single-USB deployments impractical; power design adds complexity in the field

Future Improvements

  • Dual-core ESP32 + W5500: Replacing ESP32-C3 with a full ESP32 (dual-core, 240 MHz) improves both throughput and client capacity. SPI wiring stays identical, so no driver changes are needed
  • W6100 for IPv6 environments: Where IPv6 support is required, W6100 (IPv4/IPv6 Dual Stack) is a drop-in upgrade path that brings native IPv6 routing without rearchitecting the system
  • Hardware TCP/IP offloading for simpler edge devices: This project intentionally routes all TCP/IP through lwIP on the MCU. For edge devices whose primary task is TCP-based data collection rather than routing, using W5500's hardwired socket engine directly would reduce MCU load significantly — a worthwhile consideration for purpose-built sensor gateways

FAQ

Q. Do I need anything beyond an ESP32-C3 SuperMini board to get started? You need a separate W5500 SPI Ethernet module. You also need an external 3.3V power supply for the W5500, since it draws up to 250 mA — more than the SuperMini's onboard regulator can deliver.

Q. Is 4 Mbps throughput enough for everyday internet use? It handles general web browsing, IoT communication, and small file transfers comfortably. A single HD stream (4–8 Mbps) sits right at the edge. For multi-stream or high-throughput scenarios, the WT32-ETH01 with LAN8720 (~15 Mbps) is the better choice.

Q. How much does enabling WireGuard VPN reduce performance? VPN adds encryption overhead on top of routing, so throughput drops further. On a single-core ESP32-C3, running VPN alongside ACL filtering and PCAP capture simultaneously is not recommended. Enable only the features you actively use.

Q. Can this connect to a corporate WPA2-Enterprise network? Yes. The firmware supports PEAP, TTLS, and TLS authentication for the WiFi uplink. Downstream wired clients receive internet access via DHCP with no special configuration required.

Q. How are firmware updates handled in the field? The Web UI's Device Management section supports OTA updates. Upload a binary from a browser, and the device flashes and reboots automatically. Partition rollback restores the previous version if an update fails.


 

Documents
Comments Write