/python_wireguard_auto_reconnect

First Version of a Programm to auto reconnect a wireguard connection on Linux

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

python_wireguard_auto_reconnect

Description of the project

This Python program checks if a wireguard connection is still alive and restarts if the connection is lost.
The programm is constantly pinging the vpn-gateway.
If the ping is a successful the programm goes to sleep for a 30 seconds and than pings again.
If the ping fails the programm restarts the wireguard connection and than pings again. After 50 failed tries the programm is timeouted for 30 minutes.

Project status

The project itself is complete and ready for use. I am open for improvments.

Requirements

Requirements for running the webui are: - python (3.x.x)
- pip (v3) or any other packetmanager
- pythonping

Installation

1. Download and Install Python.
For windows go to (https://www.python.org/downloads/)
For linux use sudo apt-get install python3.x
2. Download and install pip-packetmanager
3. Install pythonping
For Windows py -3 -m pip install pythonping
For Linux pip3 install pythonping
4. Now run the Wireguard_Reconnect.py - File For Windows py -3 Wireguard_Reconnect.py
For Linux python3 Wireguard_Reconnect.py

Additional notes:

- If you want to use it on another operating system you only have to change the line "os.system('sudo wg-quick down wg0')" and "os.system('sudo wg-quick up wg0').
- Other values like the timeouts can be adjusted as well.
- The program must always be run with elevated privileges because of the package pythonping.