This project integrates OpenVPN on MikroTik routers with a Debian-based VPN server and provides a user-friendly Flask web interface for managing VPN profiles. The solution is designed to simplify VPN management tasks such as creating users, exporting certificates, and generating .ovpn
configuration files.
- MikroTik OpenVPN Server Integration: Leverages MikroTik RouterOS to serve as the OpenVPN server.
- Debian VPN Management: Hosts the Flask application and handles certificate generation and file export.
- Flask-Based Web Interface: Simplifies user interaction by providing an accessible web platform for creating and managing VPN profiles.
- Certificate Management: Automatically generates and exports the necessary certificates and keys for each VPN client.
- OVPN File Generation: Creates fully configured
.ovpn
files for easy client-side setup.
- A MikroTik router with OpenVPN support.
- A Debian-based server or VM to host the Flask application.
- Python 3.x with the following libraries:
Flask
paramiko
librouteros
- MikroTik RouterOS properly configured to support OpenVPN.
- OpenVPN client software for end users.
-
Clone the Repository:
git clone https://github.com/davidnicola95/OpenVPN-MikroTik-Flask.git cd OpenVPN-MikroTik-Flask
-
Install Dependencies: Use
pip
to install the necessary Python libraries:pip install Flask paramiko librouteros
-
Configure Environment Variables: Modify these values within app.py:
ROUTER_IP=X.X>X.X SSH_USERNAME=USERNAME SSH_PRIVATE_KEY=/path/to/private_key
-
Run the Flask App: Start the Flask application:
python3 app.py
-
Access the Web Interface: Open a browser and navigate to:
http://<server_ip>:4444
- Navigate to the web interface.
- Use the provided form to create a new VPN user.
- Download the
.ovpn
configuration file for the created user. - Import the
.ovpn
file into your OpenVPN client to connect to the VPN.
- Ensure that the private key and sensitive configuration files are not exposed in the repository or logs.
- Use HTTPS for accessing the Flask web interface in a production environment.
Contributions to improve or expand this project are welcome. Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.
This project is intended for educational and personal use. Ensure compliance with local laws and IT policies when using VPNs.