Automated Dual-Server VPN Setup with Telegram Bot Integration -- 3
Budget: $10 – $30 USD
Project Overview
This project involves setting up a WireGuard-based VPN system across two Ubuntu servers (versions 22.04 to 24.04) with an automated Bash script for deployment and a Telegram bot for user authentication and IP address management.
The system is designed for traffic forwarding, where:
Server 1 (Entry Point) receives VPN connections from users.
Server 2 (Exit Point) routes the traffic so that clients appear to be browsing from Server 2.
The solution must ensure seamless NAT configuration, secure traffic forwarding, and dynamic IP assignment using a Telegram bot.
Deliverables & Features
1️⃣ WireGuard VPN Dual-Server Setup & Traffic Forwarding
✅ Automated deployment of WireGuard VPN on two Ubuntu servers.
✅ Traffic flows from Server 1 (Entry) → Server 2 (Exit).
✅ IP masquerading (NAT) and routing configuration to ensure clients appear to be coming from Server 2.
✅ Firewall rules for DNS leak protection, port forwarding, and security hardening.
✅ Persistent VPN setup to ensure WireGuard starts on reboot.
Proof of completion:
Screenshots/logs of WireGuard installation on both servers.
Output of wg show on both servers to verify active peers.
Test connection proof by running curl ifconfig.me from the client (should return Server 2's IP).
Output of iptables -t nat -L -v -n to confirm NAT and forwarding rules.
Verification of VPN auto-start after reboot (systemctl status wg-quick@wg0).
2️⃣ Automated Deployment Script (Bash)
✅ A fully automated Bash script for setting up WireGuard on both servers.
✅ The script should:
Install WireGuard and configure firewall rules (UFW).
Enable IP forwarding and NAT for seamless traffic routing.
Set up WireGuard peer-to-peer communication.
Configure systemd service to ensure VPN auto-starts on reboot.
Implement error handling and logs for debugging.
Proof of completion:
The Bash script (commented and structured).
A demo video or live screen-share of script execution.
GitHub repository or ZIP file containing:
Bash script
Configuration files
Systemd service files
Testing proof:
Deployment on a fresh Ubuntu 22.04/24.04 server.
Screenshots of successful VPN connection and traffic forwarding.
3️⃣ Telegram Bot Integration (Fully Functional)
✅ A Python-based Telegram bot to allow users to:
Authenticate using Telegram and register their VPN session.
Retrieve their assigned VPN IP via /getip command.
Request a new IP from a preloaded pool via /changeip command.
Check VPN server status via /status command. ✅ The bot must integrate with a database (e.g., SQLite, PostgreSQL) to store:
User IDs
Assigned IPs
IP usage logs ✅ Admin functionalities:
Upload configuration files via Telegram to add new IPs.
Monitor user activity logs.
Proof of completion:
Python script for the Telegram bot (structured and commented).
Demo video showcasing:
/start → User registration
/getip → Show assigned IP
/changeip → Assign a new IP
/status → VPN server status
Testing proof:
Bot deployed and responding to test commands.
Logs showing correct IP assignments & dynamic IP switching.
Output of journalctl -u bot.service -n 50 to check for errors.
4️⃣ Security & Optimization
✅ WireGuard Hardening:
Use strong cryptographic keys for authentication.
Optimize handshake settings for better performance.
✅ Fail2Ban & UFW Configuration:
Fail2Ban to prevent unauthorized access attempts.
UFW firewall rules to protect VPN servers. ✅ Automated Log Rotation:
Implement log rotation to prevent log bloat. ✅ Monitoring & Alerts:
Notify the admin if the VPN fails or bot stops responding.
Proof of completion:
Configuration files for Fail2Ban, UFW, and log rotation.
Testing proof:
Run sudo ufw status and fail2ban-client status to confirm rules.
Attempt unauthorized access and verify that it is blocked.
Reboot servers and verify that:
VPN auto-restarts (systemctl status wg-quick@wg0).
Telegram bot remains functional.
5️⃣ Documentation & User Guide
✅ Step-by-step guide (Markdown or PDF) including:
Setup & deployment instructions for VPN and Telegram bot.
How to add/remove users and assign new IPs.
Bot integration guide with command explanations.
Troubleshooting steps for common issues. ✅ Screenshots with explanations for:
Managing users, IPs, and configurations.
Setting up and maintaining the VPN.
Proof of completion:
Completed PDF/Markdown guide.
Proof that a non-technical user can follow the guide.
Testing & Verification Requirements
To consider the project successfully delivered, the following testing steps must pass:
✔ VPN Functional Test
Connect a client to Server 1.
Run curl ifconfig.me → Must return Server 2’s IP.
Run ping 10.0.0.2 → Must receive responses.
✔ Telegram Bot Functional Test
Run /start → Register user.
Run /getip → Shows assigned IP.
Run /changeip → Assigns a new IP dynamically.
Run /status → Shows VPN server status.
✔ Security Test
Run fail2ban-client status → Must show active jails.
Attempt an unauthorized login → Must be blocked and logged.
✔ Reboot Test
Restart both servers and verify:
VPN auto-restarts (systemctl status wg-quick@wg0).
Telegram bot remains functional.
Expected Deliverables Checklist
✅ WireGuard VPN setup (screenshots, logs, and traffic test results).
✅ Automated Bash script for deployment.
✅ Fully functional Telegram bot (Python script & test results).
✅ Security configurations (Fail2Ban, firewall, log rotation).
✅ Comprehensive documentation (setup guide & troubleshooting).
Project Completion Criteria
✅ All VPN traffic must successfully route through Server 2.
✅ Clients should connect to Server 1 and appear from Server 2.
✅ Telegram bot should correctly authenticate users and assign IPs.
✅ Security measures should be implemented & tested.
✅ Detailed documentation should be provided for future management.
This is the complete end-to-end scope of the project, ensuring full functionality, security, and maintainability of the VPN system and Telegram bot integration.
This project involves setting up a WireGuard-based VPN system across two Ubuntu servers (versions 22.04 to 24.04) with an automated Bash script for deployment and a Telegram bot for user authentication and IP address management.
The system is designed for traffic forwarding, where:
Server 1 (Entry Point) receives VPN connections from users.
Server 2 (Exit Point) routes the traffic so that clients appear to be browsing from Server 2.
The solution must ensure seamless NAT configuration, secure traffic forwarding, and dynamic IP assignment using a Telegram bot.
Deliverables & Features
1️⃣ WireGuard VPN Dual-Server Setup & Traffic Forwarding
✅ Automated deployment of WireGuard VPN on two Ubuntu servers.
✅ Traffic flows from Server 1 (Entry) → Server 2 (Exit).
✅ IP masquerading (NAT) and routing configuration to ensure clients appear to be coming from Server 2.
✅ Firewall rules for DNS leak protection, port forwarding, and security hardening.
✅ Persistent VPN setup to ensure WireGuard starts on reboot.
Proof of completion:
Screenshots/logs of WireGuard installation on both servers.
Output of wg show on both servers to verify active peers.
Test connection proof by running curl ifconfig.me from the client (should return Server 2's IP).
Output of iptables -t nat -L -v -n to confirm NAT and forwarding rules.
Verification of VPN auto-start after reboot (systemctl status wg-quick@wg0).
2️⃣ Automated Deployment Script (Bash)
✅ A fully automated Bash script for setting up WireGuard on both servers.
✅ The script should:
Install WireGuard and configure firewall rules (UFW).
Enable IP forwarding and NAT for seamless traffic routing.
Set up WireGuard peer-to-peer communication.
Configure systemd service to ensure VPN auto-starts on reboot.
Implement error handling and logs for debugging.
Proof of completion:
The Bash script (commented and structured).
A demo video or live screen-share of script execution.
GitHub repository or ZIP file containing:
Bash script
Configuration files
Systemd service files
Testing proof:
Deployment on a fresh Ubuntu 22.04/24.04 server.
Screenshots of successful VPN connection and traffic forwarding.
3️⃣ Telegram Bot Integration (Fully Functional)
✅ A Python-based Telegram bot to allow users to:
Authenticate using Telegram and register their VPN session.
Retrieve their assigned VPN IP via /getip command.
Request a new IP from a preloaded pool via /changeip command.
Check VPN server status via /status command. ✅ The bot must integrate with a database (e.g., SQLite, PostgreSQL) to store:
User IDs
Assigned IPs
IP usage logs ✅ Admin functionalities:
Upload configuration files via Telegram to add new IPs.
Monitor user activity logs.
Proof of completion:
Python script for the Telegram bot (structured and commented).
Demo video showcasing:
/start → User registration
/getip → Show assigned IP
/changeip → Assign a new IP
/status → VPN server status
Testing proof:
Bot deployed and responding to test commands.
Logs showing correct IP assignments & dynamic IP switching.
Output of journalctl -u bot.service -n 50 to check for errors.
4️⃣ Security & Optimization
✅ WireGuard Hardening:
Use strong cryptographic keys for authentication.
Optimize handshake settings for better performance.
✅ Fail2Ban & UFW Configuration:
Fail2Ban to prevent unauthorized access attempts.
UFW firewall rules to protect VPN servers. ✅ Automated Log Rotation:
Implement log rotation to prevent log bloat. ✅ Monitoring & Alerts:
Notify the admin if the VPN fails or bot stops responding.
Proof of completion:
Configuration files for Fail2Ban, UFW, and log rotation.
Testing proof:
Run sudo ufw status and fail2ban-client status to confirm rules.
Attempt unauthorized access and verify that it is blocked.
Reboot servers and verify that:
VPN auto-restarts (systemctl status wg-quick@wg0).
Telegram bot remains functional.
5️⃣ Documentation & User Guide
✅ Step-by-step guide (Markdown or PDF) including:
Setup & deployment instructions for VPN and Telegram bot.
How to add/remove users and assign new IPs.
Bot integration guide with command explanations.
Troubleshooting steps for common issues. ✅ Screenshots with explanations for:
Managing users, IPs, and configurations.
Setting up and maintaining the VPN.
Proof of completion:
Completed PDF/Markdown guide.
Proof that a non-technical user can follow the guide.
Testing & Verification Requirements
To consider the project successfully delivered, the following testing steps must pass:
✔ VPN Functional Test
Connect a client to Server 1.
Run curl ifconfig.me → Must return Server 2’s IP.
Run ping 10.0.0.2 → Must receive responses.
✔ Telegram Bot Functional Test
Run /start → Register user.
Run /getip → Shows assigned IP.
Run /changeip → Assigns a new IP dynamically.
Run /status → Shows VPN server status.
✔ Security Test
Run fail2ban-client status → Must show active jails.
Attempt an unauthorized login → Must be blocked and logged.
✔ Reboot Test
Restart both servers and verify:
VPN auto-restarts (systemctl status wg-quick@wg0).
Telegram bot remains functional.
Expected Deliverables Checklist
✅ WireGuard VPN setup (screenshots, logs, and traffic test results).
✅ Automated Bash script for deployment.
✅ Fully functional Telegram bot (Python script & test results).
✅ Security configurations (Fail2Ban, firewall, log rotation).
✅ Comprehensive documentation (setup guide & troubleshooting).
Project Completion Criteria
✅ All VPN traffic must successfully route through Server 2.
✅ Clients should connect to Server 1 and appear from Server 2.
✅ Telegram bot should correctly authenticate users and assign IPs.
✅ Security measures should be implemented & tested.
✅ Detailed documentation should be provided for future management.
This is the complete end-to-end scope of the project, ensuring full functionality, security, and maintainability of the VPN system and Telegram bot integration.