Skip to main content

VPN-Chainer 🛡️

A powerful WireGuard VPN chaining tool with dynamic routing, automated service control, and API support.

VPN-Chainer WireGuard Python PyPI

🔹 Overview

VPN-Chainer allows you to chain multiple WireGuard VPNs together, dynamically reordering routes for improved anonymity and security. It includes auto-installation as a system service, API-based VPN rotation, and a customizable pre/post spin-up/down hook system.

Now, you can optionally test VPN speeds and select the fastest VPNs using --fastest.

📦 Available on PyPI - Install easily with pip install vpn-chainer


⚡ Features

✅ Multi-Hop VPN Chaining – Connect through multiple WireGuard VPNs in random order.
✅ Speed-Tested VPN Selection – Use --fastest to pick the top VPNs based on download speed.
✅ Automatic Routing & Firewall Rules – Seamless packet forwarding between VPN interfaces.
✅ Pre/Post Execution Hooks – Run custom scripts before and after VPN chain events.
✅ Remote API Support – Securely rotate VPNs via a web API.
✅ Auto-Installation as a Systemd Service – Persistently run VPN-Chainer in the background.


🚀 Installation

1️⃣ Prerequisites

Ensure you have Python 3 and WireGuard installed:

sudo apt update  
sudo apt install -y python3 python3-pip wireguard  

2️⃣ Install VPN-Chainer from PyPI

Easy installation via pip:

sudo pip install vpn-chainer

🔄 Alternative: Install from Source

If you prefer to install from source:

git clone https://github.com/a904guy/VPN-Chainer.git  
cd VPN-Chainer  
sudo python3 setup.py install

⚡ Quick Start

After installation, you can immediately start using VPN-Chainer:

# Install the package
sudo pip install vpn-chainer

# Set up your WireGuard configs in /etc/wireguard/
# Then run with 2 VPNs
sudo vpn-chainer 2

# Or use the fastest VPNs
sudo vpn-chainer 3 --fastest

🛠️ Usage

🔹 Basic Usage

sudo vpn-chainer <number_of_vpns>  

For example, to create a 3-hop VPN chain:

sudo vpn-chainer 3  

🔹 Use Speed Testing to Select Fastest VPNs

To test all VPNs first and pick the top N fastest VPNs, use --fastest:

sudo vpn-chainer 3 --fastest  

🚀 This will:

  • Test all available VPNs in /etc/wireguard/
  • Select the top 3 fastest VPNs
  • Use them in the VPN chain

🔹 Install as a Systemd Service

Automatically install and enable the VPN-Chainer service:

sudo vpn-chainer 3 --auto-install  

Once installed, it will start automatically on boot.

To stop or restart the service:

sudo systemctl stop vpn-chainer  
sudo systemctl restart vpn-chainer  

To view logs:

sudo journalctl -u vpn-chainer -f  

🔗 API Usage

Rotate VPN Remotely

VPN-Chainer provides an API to trigger VPN rotations. The API key is displayed on startup:

[INFO] VPN-Chainer API running at:  
🔗 http://127.0.0.1:5000/rotate_vpn?key=6a1f-45e9...  

To rotate VPNs:

curl -X GET "http://127.0.0.1:5000/rotate_vpn?key=YOUR_API_KEY"  

This will:

  • Tear down the current VPN chain.
  • Randomly select new VPN configs (or use fastest if started with --fastest).
  • Reestablish routing and firewall rules.

⚙️ Hook System (Pre/Post Execution Scripts)

VPN-Chainer allows you to run scripts before and after VPN activation/deactivation.

🔹 Hook Script Locations

Scripts should be placed in:

/etc/vpn-chainer/hooks/  
Hook Script Name Triggered When
pre-spin-up.sh Before the VPN chain starts
post-spin-up.sh After the VPN chain is established
pre-spin-down.sh Before VPNs are torn down
post-spin-down.sh After all VPNs have shut down

🔹 Example Hook: Restart Tor After VPN Starts

Edit /etc/vpn-chainer/hooks/post-spin-up.sh:

# !/bin/bash  

echo "[HOOK] Restarting Tor for anonymity..."  
systemctl restart tor  

Then enable the hook:

chmod +x /etc/vpn-chainer/hooks/post-spin-up.sh  

📂 Configuration Files

VPN-Chainer automatically selects random WireGuard config files from:
/etc/wireguard/*.conf

Ensure that at least the number of VPN configs requested exists. Additionally the Address line is required.

Example VPN config:

[Interface]  
PrivateKey = <YOUR_PRIVATE_KEY>  
Address = 10.13.36.109/24  
DNS = 10.8.0.1  

[Peer]  
PublicKey = <PEER_PUBLIC_KEY>  
Endpoint = 10.10.10.24:51820  
AllowedIPs = 0.0.0.0/0  
PersistentKeepalive = 25  

❓ Troubleshooting

🔸 VPN Doesn't Start

  • Check that you have WireGuard installed:
which wg  

If missing, install it:

sudo apt install wireguard  
  • Ensure you have enough VPN config files in /etc/wireguard/.

🔸 Systemd Service Not Running

  • Check status:
sudo systemctl status vpn-chainer  
  • Restart it:
sudo systemctl restart vpn-chainer  

🔸 API Not Responding

  • Ensure VPN-Chainer is running:
sudo systemctl status vpn-chainer  
  • Check firewall rules (port 5000 must be open):
sudo ufw allow 5000/tcp  

📜 Roadmap

✔️ Multi-Hop Randomization
✔️ Pre/Post Execution Hooks
✔️ Auto-Install as a Systemd Service
✔️ Speed-Tested VPN Selection (--fastest) (Added in v1.1)
🔜 Web Dashboard for Control & Logs
🔜 VPN Failover Detection ❓❓
🔜 Split-Tunneling (Selective Routing) ❓❓
🔜 Submit Your Ideas Via Issues


🤝 Contributing

Want to improve VPN-Chainer? Contributions are welcome! Fork the repository and submit a PR.

  1. Fork & Clone
    git clone https://github.com/a904guy/VPN-Chainer.git cd vpn-chainer

  2. Make Changes & Test
    sudo python3 vpn-chainer.py 3

  3. Submit a Pull Request


📜 License

This project is licensed under the MIT License.


👨‍💻 Author

💡 Created by Andy Hawkins
🌐 GitHub: a904guy GitHub Profile


🚀 VPN-Chainer is your ultimate tool for anonymous, multi-hop VPN tunneling! 🔥 💬 Have questions or feature requests? Open an Issue on GitHub! 😎

Metadata

Release files for vpn-chainer 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vpn-chainer 1.3.2
File Size Uploaded
vpn_chainer-1.3.2.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vpn-chainer 1.3.2
File Interpreter ABI Platform
vpn_chainer-1.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.1 kB

Release files / vpn_chainer-1.3.2.tar.gz

Download URL vpn_chainer-1.3.2.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cc62badaa20b76f4fb2384714743252de6701ed638c1f1a3a959f28cb9efdc17
BLAKE2b-256 checksum
How to use checksums
e002a215ccab123cedcbcf811a5982957e2c3f47a7695498198f4dc3d159f2f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / vpn_chainer-1.3.2-py3-none-any.whl

Download URL vpn_chainer-1.3.2-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c15af94b3a5459159fa0ab35a3125d836d2f430c3519b102adc41c8bf9b2a9af
BLAKE2b-256 checksum
How to use checksums
775cbad7e8c8288dfe7336b6f928338d077c8bf765f88b5ef40fb057ad143090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

1.3.2 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page