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

https://github.com/coralesoft/openwrt-wireguard-installer

Interactive WireGuard installer for OpenWrt. Generates peer configs with QR codes, applies UCI network/firewall changes, and supports rollback.
https://github.com/coralesoft/openwrt-wireguard-installer

firewall network-automation network-tools networking openwrt openwrt-configuration openwrt-installation qr-code router security shell-script uci vpn wireguard

Last synced: 3 months ago
JSON representation

Interactive WireGuard installer for OpenWrt. Generates peer configs with QR codes, applies UCI network/firewall changes, and supports rollback.

Awesome Lists containing this project

README

          

# OpenWrt WireGuard Ineractive Installer

An interactive shell script to quickly and safely configure a WireGuard VPN server on an OpenWrt router.

It guides you through generating keys, applying network and firewall settings, and creating ready-to-import `.conf` files for client devices β€” with optional QR code output for mobile use and built-in rollback for peace of mind.

v2025.7.5
---

## ✨ Features

- Interactive prompts for all setup variables
- Generates secure keypairs and `.conf` files for each peer
- Optional QR code output for mobile devices
- Automatically applies UCI network and firewall rules
- Creates timestamped backups and supports rollback
- Built specifically for OpenWrt

---

## 🧱 Requirements

- OpenWrt 23.05 or newer (tested on Raspberry Pi CM router and a x86 based router)
- Installed packages:
```sh
opkg update
opkg install wireguard-tools luci-app-wireguard
```
- (Optional for QR codes):
```sh
opkg install qrencode
```

---

## πŸ“₯ Installation

1. **Download the script**:
```sh
curl -O https://raw.githubusercontent.com/Coralesoft/openwrt-wireguard-installer/main/wg-openwrt-installer.sh
chmod +x wg-openwrt-installer.sh
```

2. **Run it ** on your OpenWrt router:
```sh
./wg-openwrt-installer.sh
```

---

## βš™οΈ Usage

The script will prompt you to:
- Name the WireGuard interface
- Set port, address, zones, and DNS
- Enter your public endpoint (`host:port`)
- Define the number of peers
- Provide each peer’s name and IP

Each peer will get:
- A secure private key
- A complete `.conf` file (for use in desktop or mobile clients)
- An optional QR code displayed in the terminal (if `qrencode` is installed)

---

## πŸ“‚ Output

All generated files are saved under:

```
/etc/wireguard/
β”œβ”€β”€ privatekey # Server key
β”œβ”€β”€ publickey # Server key
└── peers/
β”œβ”€β”€ phone.conf
β”œβ”€β”€ phone-privatekey
β”œβ”€β”€ phone-publickey
└── ...
```

---

## πŸ”„ Rollback

At the end of the setup, you’ll be prompted to roll back your changes.
If confirmed, it restores:

- `/etc/config/network.bak.`
- `/etc/config/firewall.bak.`

---

## Example

A sample generated `.conf` for a peer:

```ini
[Interface]
PrivateKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Address = 192.168.20.2/32
DNS = 192.168.20.1

[Peer]
PublicKey = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
Endpoint = vpn.example.com:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
```

Import this into the WireGuard app on iOS/Android, or use with `wg-quick` on desktop.

---

## πŸ“Œ Roadmap

- [ ] Add uninstall/teardown script - in progress
- [ ] Regenerate or revoke peer keys
- [ ] Add script to regenerate peer QR codes

---

## 🧹 Uninstall

To remove all WireGuard configuration, keys, peers, and firewall rules, use the included uninstall script.

### Usage

Run normally to uninstall:

```sh
./wg-uninstall.sh
```

Run in dry-run mode to preview what will be removed:

```sh
./wg-uninstall.sh --dry-run
```
---

## πŸ’¬ Feedback

Pull requests, issues, and suggestions are welcome.
Open an issue at [github.com/Coralesoft/Openwrt-Wireguard-Installer/issues](https://github.com/Coralesoft/Openwrt-Wireguard-Installer/issues).

## Support the Project
If this project helps you streamline your OpenWrt setup and you’d like to support ongoing development, consider buying me a coffee. Your contribution keeps the creativity flowing and helps sustain future updates.


Buy Me A Coffee