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

https://github.com/davyjonescodes/wireguardnamespace

Create isolated Linux network namespaces optionally routed through WireGuard VPN for sandboxed applications, regional testing, or privacy control.
https://github.com/davyjonescodes/wireguardnamespace

bash namespace networking vpn wireguard

Last synced: about 1 month ago
JSON representation

Create isolated Linux network namespaces optionally routed through WireGuard VPN for sandboxed applications, regional testing, or privacy control.

Awesome Lists containing this project

README

          

# WireguardNamespace


Logo




**WireguardNamespace** is a standalone Bash script for setting up isolated Linux network namespaces with optional WireGuard VPN routing. It's ideal for sandboxing applications, routing specific programs through VPNs, or testing in a clean network environment.

---

## โœจ Features

- ๐Ÿงฑ **Namespace Isolation**: Create isolated network spaces for apps or testing.
- ๐Ÿ” **WireGuard Support**: Automatically connects VPN via `wg-quick` (if enabled).
- ๐Ÿงน **Clean Teardown**: Easily delete namespace, interfaces, and routing rules.
- ๐Ÿท๏ธ **Custom Naming**: Use `--name ` to manage multiple namespaces.
- ๐Ÿšซ **VPN Optional**: Use `--no-vpn` for direct internet access without tunneling.

---

## ๐Ÿš€ Usage

```bash
sudo ./WireguardNamespace.sh [--name ] [interface] [--no-vpn] [--teardown]
````

### Arguments

| Option | Description |
| ------------ | ---------------------------------------------------------------- |
| `--name` | Set custom namespace name (default: `vpnspace`) |
| `--no-vpn` | Skip VPN setup (provides regular internet in namespace) |
| `--teardown` | Remove namespace, veth, and NAT rules |
| `interface` | Network interface to use (e.g. `eth0`). Auto-selected if omitted |

---

### โœ… Examples

```bash
# Default setup with VPN
sudo ./WireguardNamespace.sh

# Create isolated namespace without VPN
sudo ./WireguardNamespace.sh --no-vpn

# Create a custom namespace called 'research'
sudo ./WireguardNamespace.sh --name research

# Teardown custom namespace
sudo ./WireguardNamespace.sh --name research --teardown
```

---

## ๐Ÿ“ฆ Requirements

* Linux with:

* `ip`, `iptables`, `wg-quick`, `curl`, `jq`
* A valid WireGuard config (default path is `/etc/wireguard/wg0.conf`)
* Root privileges (`sudo`)

---

## ๐Ÿ“„ License

This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.

---

## ๐Ÿค Contributing

Want to improve this script or add new features? Feel free to fork and submit a pull request. Ideas and suggestions welcome!

---

## ๐Ÿ“ฌ Support

Open an issue or email [devjonescodes@gmail.com](mailto:devjonescodes@gmail.com) if you need help or want to collaborate.