Auto-DynamicIP

Auto-DynamicIP is a lightweight Bash automation script designed specifically for users with dynamic public IP addresses. It not only monitors IP changes in real-time by polling multiple APIs but also triggers deep IP quality detection when a change occurs, generating a beautiful image report and pushing it immediately to your phone via Telegram.

🚀 Key Features

  • Multi-Source IP Detection: Polls multiple reliable APIs (such as ip.sb, icanhazip.com, etc.) to obtain the current public IP, ensuring stability.
  • IP Change Monitoring: Automatically records the previous IP and triggers subsequent operations only when the IP changes.
  • Automatic Quality Detection: Integrates the IP.Check.Place script to automatically assess IP quality (includes -E enhanced mode).
  • Visual Report Generation: Uses ansilove to convert terminal ANSI output into high-quality PNG images.
  • Telegram Notifications: Sends change details (new/old IP, time) and the generated report image to a specified Telegram Chat.
  • Logging: Detailed records of the detection process, error messages, and sending status in a log file.
  • Automatic Cleanup: Automatically cleans up generated temporary images after successful sending.

📋 Requirements

Before using this script, ensure your system has the following dependencies installed:

  • curl (For network requests)
  • bash (Script interpreter)
  • ansilove (Core Dependency: Used to convert ANSI text to PNG images)
  • grep, sed, awk (Standard text processing tools)

🛠️ Installation and Configuration

1. Download the Script

Download monitor_ip.sh from the GitHub Repository to your server or local machine.

2. Grant Execution Permissions

chmod +x monitor_ip.sh

3. Configure the Script

Open the monitor_ip.sh file and modify the configuration section at the top:

# Telegram Bot Configuration
TG_BOT_TOKEN="YOUR_BOT_TOKEN"    # Get from @BotFather
TG_CHAT_ID="YOUR_CHAT_ID"        # User ID or Group ID to receive messages

# File Path Configuration
IP_LOG_FILE="/root/.current_ip_log"  # Path to record current IP
IMAGE_DIR="/root"                    # Directory for image generation
LOG_FILE="/var/log/ip_monitor.log"   # Log file path

Note: Ensure the script has write permissions for the configured directories (e.g., /root or /var/log). If running as a standard user, it is recommended to change these to paths within the user’s home directory (e.g., ~/ip_monitor.log).

📖 Usage

Manual Execution

Run the script directly for testing:

./monitor_ip.sh

If it is the first run (or there is no history), it will record the current IP. If run again and the IP has not changed, the script will exit silently.

Scheduled Task (Cron)

It is recommended to add the script to crontab for automated monitoring. For example, to check every 5 minutes:

  1. Edit crontab:

    crontab -e
  2. Add the following line:

    */5 * * * * /path/to/monitor_ip.sh

📝 Log Viewing

The script’s execution logs are saved in the configured LOG_FILE (default /var/log/ip_monitor.log). You can view them using:

tail -f /var/log/ip_monitor.log

🔄 Workflow

  1. Start: The script starts and attempts to retrieve the current public IP from APIs.
  2. Compare: It reads the locally cached old IP and compares it with the new one.
  3. Action (If Changed):
    • Updates the local cache.
    • Calls the remote script bash <(curl -sL IP.Check.Place) -4 -E for detection.
    • Captures the output and uses ansilove to generate a PNG image.
    • Sends a Telegram notification (including new/old IP comparison and the image).
    • Cleans up temporary files.
  4. No Change: Exits without performing any operations.

📄 License

This project is open-sourced under the GNU Affero General Public License v3.0.

ℹ️ About

Auto-DynamicIP is created to simplify the monitoring of dynamic IPs and provide visual reports on IP quality changes. Check out the GitHub Repository for more details.

Dynamic IP Monitor

Author

Shayne Wong

Publish Date

02 - 13 - 2026

Last Modified

02 - 17 - 2026

License

Shayne Wong

Avatar
Shayne Wong

All time is no time when it is past.

Friend Links
Blog Statistics

Total Posts

35

Category

5

Tag

20

Total Words

33,978

Reading Time

174 mins