An open API service indexing awesome lists of open source software.

https://github.com/ssut/WSL2-HyperV-Firewall-Manager

WSL2 Hyper-V Firewall Management GUI for mirrored WSL2 networking
https://github.com/ssut/WSL2-HyperV-Firewall-Manager

firewall-rules gui hyperv windows wsl2

Last synced: 4 months ago
JSON representation

WSL2 Hyper-V Firewall Management GUI for mirrored WSL2 networking

Awesome Lists containing this project

README

          


WSL2 Hyper-V Firewall Manager

WSL2 Hyper-V Firewall Manager


A Rust desktop application for managing WSL2 Hyper-V firewall rules with a git-like draft/commit workflow and full rollback capability.

---

![Screenshot](docs/screenshot.png)

## Overview

This application provides a graphical interface to manage Windows Hyper-V firewall rules specifically for WSL2. It uses the `Get-NetFirewallHyperVRule`, `New-NetFirewallHyperVRule`, and `Remove-NetFirewallHyperVRule` PowerShell cmdlets under the hood.

## Why

Running servers inside WSL2 is easy.
Accessing them from outside your machine is not.

WSL2 relies on Hyper-V networking, which means exposing ports often requires manual firewall configuration using PowerShell commands — and those settings are fragile and repetitive.

This project was built to make WSL2 port exposure trivial:
just click, enter, and your WSL2 service is reachable from the outside.

## Features

### Core Features

- **Visual Rule Management** - View and manage all Hyper-V firewall rules for WSL2
- **Git-like Safe Workflow** - Stage changes (add/remove/modify) before committing them
- **Snapshot History** - Automatic snapshots before each commit with full rollback capability
- **UAC Elevation on Demand** - Read rules without admin rights; elevation requested only for mutations
- **WSL Config Validation** - Checks for `networkingMode=mirrored` in `.wslconfig`

### Auto-Discover

- **WSL Status Monitoring** - Real-time indicator showing whether WSL is running
- **Automatic Port Discovery** - Detects listening TCP ports inside WSL using `lsof`
- **One-Click Rule Creation** - Suggests firewall rules for discovered ports with a single click to add
- **Smart Filtering** - Skips ports that already have rules or were dismissed

## Requirements

- Windows 11 with WSL2 installed (Version 22H2 or higher)
- WSL2 configured with mirrored networking mode

### WSL2 Configuration

This application requires WSL2 mirrored networking mode. Add to `~/.wslconfig`:

```ini
[wsl2]
networkingMode=mirrored
```

Then restart WSL: `wsl --shutdown`

## Installation

Download the latest release from the [Releases](https://github.com/ssut/wsl2-hyperv-firewall-manager/releases) page.

## Building from Source

```bash
# Clone the repository
git clone https://github.com/ssut/wsl2-hyperv-firewall-manager
cd wsl2-hyperv-firewall-manager

# Build in release mode
cargo build --release

# The binary will be at target/release/wsl2-hyperv-firewall-manager.exe
```

## Usage

1. **Launch the application** - Rules are loaded automatically (no admin required for viewing)
2. **Stage changes** - Add, remove, or modify rules; changes are staged but not applied
3. **Commit changes** - Click "Commit" to apply all staged changes (requires admin elevation)
4. **Rollback if needed** - Use the History panel to restore any previous snapshot

### Auto-Discover Ports

1. Start WSL and run your services (e.g., `python -m http.server 8000`)
2. The status bar shows WSL status with a green indicator when running
3. Auto-discover activates automatically when WSL starts
4. Floating notifications appear for newly detected ports
5. Click "Add" to stage a firewall rule, or dismiss to ignore

## Architecture

### Technology Stack

| Component | Technology | Version |
| ---------------------- | --------------------- | ------------- |
| UI Framework | gpui + gpui-component | 0.2.2 / 0.5.0 |
| PowerShell Integration | rustclr | 0.3.4 |
| State Persistence | sled | 0.34 |
| Serialization | serde + serde_json | 1.x |
| Async Runtime | tokio | 1.x |
| Error Handling | anyhow + thiserror | 1.x / 2.x |

## License

MIT License