---
title: "Firewall_on_FPGA"
url: "https://maker.wiznet.io/irina/projects/firewall-on-fpga/"
markdown_url: "https://maker.wiznet.io/irina/projects/firewall-on-fpga/md"
type: "UCC: User Created Content"
author: "StefanGutu"
author_url: "https://github.com/StefanGutu/Firewall_on_FPGA"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "StefanGutu"
original_url: "https://github.com/StefanGutu/Firewall_on_FPGA"
published: "2026-07-06"
language: "en"
likes: 0
views: 196
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Firewall_on_FPGA

> FPGA firewall (Arty Z7-20 + W5500) by a Romania-based author @StefanGutu. Detects IP/ARP spoofing with HW rule-based filtering and a WebSocket monitor.

Original author: StefanGutu (source: https://github.com/StefanGutu/Firewall_on_FPGA)

## Article

![](https://maker.wiznet.io/upload/ckeditor5/201041082%5F1783328508%2Epng)

### 프로젝트가 하는 일

이 프로젝트(**Firewall on FPGA**, 제작자 **@StefanGutu, 루마니아(루마니아어권) 개발자 추청**)는 **Arty Z7-20(Zynq-7000 기반 FPGA 개발보드)** 위에 구현한 **스푸핑 탐지 방화벽**입니다. 핵심은 소프트웨어와 하드웨어의 역할 분담입니다.

- **소프트웨어 서브시스템** (Zynq ARM 코어 / PetaLinux): 보안 메커니즘, 패킷 관리, 시스템 제어 같은 복잡한 처리 담당

- **하드웨어 서브시스템** (FPGA 로직): 사용자가 입력한 규칙에 따라 실제 **패킷 필터링**을 고속으로 수행

보안 관점에서 **IP 스푸핑과 ARP 스푸핑 공격 방어**를 제공하며, 필터링 규칙은 **동작 중(runtime)에 동적으로** 변경할 수 있습니다. 또한 **WebSocket 서버 + 웹 인터페이스**를 통해 탐지된 이벤트를 실시간으로 모니터링합니다.

**네트워크 포트 구성**: Arty Z7-20에는 **Gigabit Ethernet이 1포트**뿐입니다. 인라인 방화벽은 in/out **2포트**가 필요하므로, **두 번째 이더넷을 W5500 모듈로 추가**하는 것입니다.

방화벽 보드는 **인터넷과 노트북 사이에 인라인(in-line)** 으로 배치됩니다.

```plaintext
Internet (router) ──eth_internet──► FPGA(Arty Z7-20) ──eth_laptop──► Laptop
```

![](https://maker.wiznet.io/upload/ckeditor5/201041082%5F1783324985%2Epng)

PetaLinux에서 IP 포워딩을 켜고, `iptables`의 **NFQUEUE**로 포워딩 트래픽을 방화벽 애플리케이션 큐(queue 0/1)로 넘겨 검사하는 구조입니다. 프론트엔드는 노트북에서 `python3 -m http.server`로 띄워 브라우저에서 탐지 이벤트를 확인합니다. 언어 구성은 VHDL ~58%, Verilog ~36%로 하드웨어 설계 비중이 큽니다.

![](https://maker.wiznet.io/upload/ckeditor5/201041082%5F1783325045%2Epng)

### WIZnet이 들어가는 위치

이 프로젝트에서 사용되는 WIZnet 제품은 **W5500**입니다.

방화벽은 트래픽이 통과하는 **두 개의 이더넷 포트(인터넷 측·노트북 측)** 가 필요한 인라인 장치입니다. Arty Z7-20의 기본 이더넷에 더해, **W5500 Ethernet 모듈이 추가 이더넷 인터페이스를 제공**해 이 2-포트 인라인 구성을 완성하는 역할로 준비물에 명시되어 있습니다. W5500은 하드웨어 TCP/IP 스택, SPI 인터페이스, 8개 독립 socket, 32KB 내부 buffer를 제공하므로, 호스트가 저수준 네트워크 처리를 오프로드하고 방화벽 로직(필터링·스푸핑 탐지)에 집중할 수 있습니다.

> 참고(정직성): README는 W5500을 **필요 부품으로 명시**하지만, 정확한 연결 포트·SPI 핀맵·초기화 세부는 문서에 나와 있지 않습니다. 정확한 역할은 저장소의 `HDL/`, `Code/` 폴더 구현을 확인하는 것이 좋습니다.

### 구현 메모

- **플랫폼**: Arty Z7-20 + PetaLinux 이미지(`FirewallExample`)를 microSD에 기록(`dd`) 후 부팅. 시리얼 콘솔은 `screen /dev/ttyUSB1 115200`.

- **인라인 배치**: 인터넷(라우터) → FPGA → 노트북. 두 이더넷 인터페이스가 모두 활성화되어야 함.

- **트래픽 라우팅/필터링 설정**(FPGA/리눅스 측):

```plaintext
  sudo sysctl -w net.ipv4.ip_forward=1   sudo iptables -F FORWARD
  sudo iptables -t nat -F POSTROUTING
  sudo iptables -t nat -A POSTROUTING -o eth_internet -j MASQUERADE
  sudo iptables -I FORWARD -i eth_laptop   -j NFQUEUE --queue-num 0   sudo iptables -I FORWARD -i eth_internet -o eth_laptop -j NFQUEUE --queue-num 1
```

- **방화벽 앱**: 프로젝트 디렉터리에서 `make` 후 컴파일된 바이너리 실행.

- **모니터링 UI**: 노트북 `frontend/` 폴더에서 `python3 -m http.server 8080` → 브라우저 `http://localhost:8080`에서 탐지 이벤트 확인.

![](https://maker.wiznet.io/upload/ckeditor5/201041082%5F1783325072%2Epng)

> Vivado Hardware Manager(ILA)로 하드웨어를 분석하려면 부팅 시 U-Boot 프롬프트에서 멈춘 뒤 세션을 연결하고, 완료 후 `boot`로 부팅을 이어갑니다.

### 유사 프로젝트

<https://maker.wiznet.io/gunn/projects/esp32-w5500-gateway-modbus/>

두 프로젝트는 모두 **W5500을 사용해 네트워크 경로 위에 놓이는 인라인 장치**라는 점에서 유사합니다. 다만 Firewall on FPGA는 **FPGA 하드웨어로 규칙 기반 패킷 필터링과 스푸핑 탐지를 수행하는 보안 장치**이고, ESP32 W5500 게이트웨이는 **프로토콜 변환(브리지) 중심의 게이트웨이**라는 점이 다릅니다.

| 항목 | Firewall on FPGA | ESP32 W5500 Gateway |
| --- | --- | --- |
| 목적 | 패킷 필터링·스푸핑 탐지(보안) | 프로토콜 브리지/게이트웨이 |
| 처리 | FPGA HW 필터링 + SW 보안 로직 | MCU 소프트웨어 처리 |
| 플랫폼 | Arty Z7-20 (Zynq-7000) | ESP32 |
| 네트워크 위치 | 인터넷↔노트북 인라인 | 네트워크↔필드버스 |
| W5500 역할 | 인라인 이더넷 인터페이스 | 이더넷 통신 인터페이스 |

### FAQ

**Q: 이 프로젝트는 무엇을 하나요?** A: Arty Z7-20 FPGA 보드에 구현한 방화벽으로, IP/ARP 스푸핑을 탐지하고 규칙 기반으로 패킷을 필터링하며, 웹 UI로 이벤트를 실시간 모니터링합니다.

**Q: W5500은 어떤 역할인가요?** A: 방화벽이 인터넷과 노트북 사이에 인라인으로 놓이려면 이더넷 포트가 2개 필요한데, W5500 모듈이 그 이더넷 인터페이스를 제공하는 준비물로 명시되어 있습니다.

**Q: 왜 FPGA로 방화벽을 만드나요?** A: 규칙 기반 패킷 필터링을 하드웨어 로직으로 처리해 고속·저지연을 노릴 수 있고, 복잡한 보안·제어 로직은 소프트웨어가 담당하는 SW-HW 분업 구조를 실험하기 위해서입니다.

**Q: 어떤 공격을 방어하나요?** A: IP 스푸핑과 ARP 스푸핑을 탐지·차단하며, 필터링 규칙을 실행 중에 동적으로 바꿀 수 있습니다.

---

## What the Project Does

This project (**Firewall on FPGA**, created by **@StefanGutu**) is a **spoofing-detection firewall** implemented on the **Arty Z7-20 (a Zynq-7000-based FPGA development board)**. Its core is a division of labor between software and hardware.

- **Software subsystem** (Zynq ARM core / PetaLinux): handles complex tasks such as security mechanisms, packet management, and system control.

- **Hardware subsystem** (FPGA logic): performs the actual **packet filtering** at high speed, according to user-defined rules.

From a security standpoint, it provides **protection against IP spoofing and ARP spoofing**, and filtering rules can be reconfigured **dynamically at runtime**. It also provides a **WebSocket server + web interface** for real-time monitoring of detected events.

The firewall board is placed **inline between the internet and a laptop**.

```plaintext
Internet (router) ──eth_internet──► FPGA(Arty Z7-20) ──eth_laptop──► Laptop
```

![](https://maker.wiznet.io/upload/ckeditor5/201041082%5F1783325336%2Epng)

On PetaLinux, IP forwarding is enabled and `iptables` **NFQUEUE** passes forwarded traffic to the firewall application queues (queue 0/1) for inspection. The frontend is served from the laptop with `python3 -m http.server`, and detected events are viewed in the browser. The language mix is ~58% VHDL and ~36% Verilog, so hardware design dominates.

![](https://maker.wiznet.io/upload/ckeditor5/201041082%5F1783325348%2Epng)

## Where WIZnet Fits

The WIZnet product used in this project is the **W5500**.

A firewall is an inline device that needs **two Ethernet ports** for traffic to pass through (internet side and laptop side). In addition to the Arty Z7-20's built-in Ethernet, the **W5500 Ethernet module provides an additional Ethernet interface** to complete this two-port inline setup, and it is listed as a required component. With its hardware TCP/IP stack, SPI interface, eight independent sockets, and 32 KB internal buffer, the W5500 lets the host offload low-level networking and focus on the firewall logic (filtering and spoofing detection).

> Honest note: The README lists the W5500 as a **required component**, but the exact port, SPI pin map, and initialization details are not documented. Check the repository's `HDL/` and `Code/` folders for the precise role.

## Implementation Notes

- **Platform**: Arty Z7-20 + a PetaLinux image (`FirewallExample`) written to a microSD with `dd`, then booted. Serial console: `screen /dev/ttyUSB1 115200`.

- **Inline placement**: internet (router) → FPGA → laptop. Both Ethernet interfaces must be active.

- **Traffic routing/filtering setup** (FPGA/Linux side):

```plaintext
  sudo sysctl -w net.ipv4.ip_forward=1   sudo iptables -F FORWARD
  sudo iptables -t nat -F POSTROUTING
  sudo iptables -t nat -A POSTROUTING -o eth_internet -j MASQUERADE
  sudo iptables -I FORWARD -i eth_laptop   -j NFQUEUE --queue-num 0   sudo iptables -I FORWARD -i eth_internet -o eth_laptop -j NFQUEUE --queue-num 1
```

- **Firewall app**: build with `make` in the project directory, then run the compiled binary.

- **Monitoring UI**: from the laptop `frontend/` folder run `python3 -m http.server 8080`, then open `http://localhost:8080` to see detected events.

![](https://maker.wiznet.io/upload/ckeditor5/201041082%5F1783325326%2Epng)

> To analyze the hardware with Vivado Hardware Manager (ILA), stop at the U-Boot prompt during boot, connect the session, then continue with `boot`.

## Similar Project

<https://maker.wiznet.io/gunn/projects/esp32-w5500-gateway-modbus/>

Both projects are similar in that they are **inline network devices that use the W5500 on the traffic path**. However, Firewall on FPGA is a **security device performing rule-based packet filtering and spoofing detection in FPGA hardware**, while the ESP32 W5500 gateway is a **protocol-bridge/gateway**.

| Item | Firewall on FPGA | ESP32 W5500 Gateway |
| --- | --- | --- |
| Purpose | Packet filtering & spoofing detection (security) | Protocol bridge/gateway |
| Processing | FPGA HW filtering + SW security logic | MCU software processing |
| Platform | Arty Z7-20 (Zynq-7000) | ESP32 |
| Network position | Inline internet↔laptop | Network↔fieldbus |
| W5500 role | Inline Ethernet interface | Ethernet communication interface |

## FAQ

**Q: What does this project do?** A: A firewall implemented on the Arty Z7-20 FPGA board that detects IP/ARP spoofing, filters packets by rules, and monitors events in real time via a web UI.

**Q: What role does the W5500 play?** A: An inline firewall between the internet and a laptop needs two Ethernet ports; the W5500 module is listed as the component providing that Ethernet interface.

**Q: Why build a firewall on an FPGA?** A: To process rule-based packet filtering in hardware logic for high speed and low latency, while software handles complex security/control logic — an SW-HW division of labor.

**Q: What attacks does it defend against?** A: It detects and blocks IP spoofing and ARP spoofing, and filtering rules can be changed dynamically at runtime.

---

Source: https://maker.wiznet.io/irina/projects/firewall-on-fpga/
