A Python utility for managing and resetting 4G routers' IP addresses. This tool provides an easy way to monitor, log, and reset your router's IP address through different methods, with multiple practical applications.
- Automatic IP address monitoring
- Multiple IP reset methods:
- Full router restart
- 4G connection cycling
- Detailed logging system
- Real-time status updates
- IP change verification
- Error handling and recovery
- Language: Python 3.6+
- Dependencies: requests
- Platform: Cross-platform (Windows, Linux, MacOS)
- License: MIT
- Python 3.6 or higher
- Access to a 4G router's admin interface
- Router credentials (admin username and password)
- Network connectivity
- Clone the repository:
git clone https://github.com/vgvr0/4G-Router-Manager.git
- Install required dependencies:
pip install -r requirements.txt
# Basic IP reset
router = Router4GIPReset("192.168.1.1", "admin", "password")
success, result = router.reset_ip_via_connection()
# For API rate limit management
if response.status_code == 429: # Too many requests
router.reset_ip_via_connection()
# Check connection status
status = router.check_connection_status()
print(f"Current connection status: {status}")
# Monitor current IP
current_ip = router.get_current_ip()
print(f"Current IP: {current_ip}")
import schedule
def daily_reset():
router = Router4GIPReset("192.168.1.1", "admin", "password")
router.reset_ip_via_connection()
# Schedule daily reset at 3 AM
schedule.every().day.at("03:00").do(daily_reset)
def auto_recovery():
router = Router4GIPReset("192.168.1.1", "admin", "password")
if not router.check_connection_status():
print("Connection lost, attempting recovery...")
router.reset_ip_via_restart()
def update_dynamic_dns():
router = Router4GIPReset("192.168.1.1", "admin", "password")
new_ip = router.get_current_ip()
update_dns_service(new_ip)
def monitor_data_usage():
router = Router4GIPReset("192.168.1.1", "admin", "password")
status = router.check_connection_status()
if status.get('data_used') > DATA_LIMIT:
send_alert("Data limit reached")
# Automatic backup system
def backup_connection():
primary_router = Router4GIPReset("192.168.1.1", "admin", "pass1")
backup_router = Router4GIPReset("192.168.1.2", "admin", "pass2")
if not primary_router.check_connection_status():
backup_router.reset_ip_via_restart()
# Testing applications with different IPs
def test_with_different_ips():
router = Router4GIPReset("192.168.1.1", "admin", "password")
for _ in range(5):
router.reset_ip_via_connection()
run_tests()
from prometheus_client import start_http_server, Gauge
# Monitoring metrics
uptime = Gauge('router_uptime', 'Router uptime in seconds')
signal_strength = Gauge('signal_strength', '4G signal strength')
def collect_metrics():
router = Router4GIPReset("192.168.1.1", "admin", "password")
status = router.check_connection_status()
uptime.set(status['uptime'])
signal_strength.set(status['signal'])
def maintenance_routine():
router = Router4GIPReset("192.168.1.1", "admin", "password")
status = router.check_connection_status()
if status.get('issues'):
router.reset_ip_via_connection()
if not router.check_connection_status():
router.reset_ip_via_restart()
- Adjust waiting times according to your router model
- Handle credentials securely
- Consider your Internet Service Provider's policies
- Implement robust error handling
- Respect service platforms' terms of service
- Monitor data usage and connection limits
- Test thoroughly in your specific environment
- Store credentials securely
- Use environment variables for sensitive data
- Implement rate limiting for reset attempts
- Monitor and log all operations
- Regular security audits recommended
- Network Management
- Python
- 4G Router
- IP Address Management
- Network Automation
- System Administration
- Network Security
- API Integration
- Business Continuity
- Development Tools
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details
If you encounter any issues or have questions:
- Check the issues section
- Review the documentation
- Open a new issue with detailed information
- Contact the maintainers
- GUI interface
- REST API implementation
- Additional router models support
- Extended monitoring capabilities
- Docker containerization
- Cloud integration features