DongleControl is a Python script for managing and monitoring 4G dongles. It allows for the automatic restarting of dongles and monitoring of their public IP addresses. Additionally, the script tracks the time of the last IP change to ensure that the dongles always have a current and functioning connection.
- Automatic Restarting: Automated powering on and off of the 4G dongles.
- IP Monitoring: Checking and updating the public IP addresses of the dongles.
- Timestamp Tracking: Logging the time of the last successful IP change.
- Regular Checks: Automated checks to determine if the last IP change occurred more than 5 minutes ago, ensuring that the dongles remain active and connected.
- Python 3.6 or higher
- Additional Python packages:
requests
,xmltodict
,schedule
,configparser
- These can be installed via
pip install -r requirements.txt
, whererequirements.txt
contains the required packages.
- These can be installed via
-
Clone the Repository:
git clone https://github.com/yourusername/DongleControl.git cd DongleControl
-
Install Dependencies:
pip install -r requirements.txt
-
Create Configuration File:
- Create a
config.ini
file in the main directory with the following content:[DONGLES] dongle_01=192.168.1.100 dongle_02=192.168.1.101 [PROXYS] proxy_01=192.168.2.100:8081 proxy_02=192.168.2.101:8082 [ASSOCIATIONS] dongle_01=proxy_01 dongle_02=proxy_02
- Adjust the IP addresses and proxy settings according to your network configuration.
- Create a
-
Run the Script:
python3 DongleControl.py
After starting the script, it will automatically check every 5 minutes to see if an IP change is necessary. Each change will be logged in the terminal, and the script will attempt to automatically resolve issues by restarting the dongles if necessary.
- Check the proxy settings if IP addresses are not being retrieved correctly.
- Ensure that your network allows external connections to
api.ipify.org
. - Consult the script's log outputs for information on actions performed and possible errors.
This project is licensed under the MIT License. Details can be found in the LICENSE
file.