A Python application that monitors your public IP address and sends Telegram notifications when it changes. Checks every minute and runs in a Docker container.
- 🔄 Monitors public IP address every 5 minutes
- 📢 Sends Telegram notifications when IP changes
- 🐳 Docker and Docker Compose support
- 🐍 Python virtual environment for local testing
- 🔒 Runs as non-root user in Docker
- 📝 Detailed logging
- Python 3.11 or higher (for local development)
- Docker and Docker Compose (for containerized deployment)
- A Telegram account and bot token
- Open Telegram and search for
@BotFather - Start a chat and send
/newbot - Follow the prompts to choose a name and username for your bot
- Copy the bot token (format:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
Option A - Using @userinfobot:
- Search for
@userinfoboton Telegram - Start a chat and send any message
- It will reply with your user ID (this is your chat ID)
Option B - Using @RawDataBot:
- Search for
@RawDataBoton Telegram - Start a chat and send any message
- Look for
"id":in the response (this is your chat ID)
Option C - Manual method:
- Send a message to your bot
- Visit:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates - Look for
"chat":{"id":in the JSON response
git clone <your-repo-url>
cd atlanteren_ip_inform_telegramchmod +x setup_venv.sh
./setup_venv.shOr manually:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtcp .env.example .envEdit .env and add your Telegram credentials:
TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_CHAT_ID=123456789
TELEGRAM_HOST_NAME=MyServer
source venv/bin/activate
python main.pyPress Ctrl+C to stop.
- Configure environment variables:
cp .env.example .env
# Edit .env with your Telegram credentials- Build and run:
docker-compose up -d- View logs:
docker-compose logs -f- Stop the service:
docker-compose down- Build the image:
docker build -t ip-monitor .- Run the container:
docker run -d \
--name ip-monitor \
--restart unless-stopped \
-e TELEGRAM_BOT_TOKEN=your-bot-token-here \
-e TELEGRAM_CHAT_ID=your-chat-id-here \
-e TELEGRAM_HOST_NAME=MyServer \
ip-monitor- View logs:
docker logs -f ip-monitor- Stop the container:
docker stop ip-monitor
docker rm ip-monitorEnvironment variables:
TELEGRAM_BOT_TOKEN(required): Your Telegram bot token from @BotFatherTELEGRAM_CHAT_ID(required): Your Telegram chat IDTELEGRAM_HOST_NAME(optional): A friendly name to identify this device/server (default: "Not Specified")
- The application fetches your public IP from
https://ifconfig.me/ip - On first run, it sends a Telegram message with your current IP
- Every 60 seconds, it checks if the IP has changed
- If changed, it sends a Telegram notification with old and new IP addresses
- All events are logged to stdout
- Verify your
TELEGRAM_BOT_TOKENis correct - Ensure your
TELEGRAM_CHAT_IDis correct (it should be a number) - Make sure you've started a chat with your bot first
- Check internet connectivity
- Verify
https://ifconfig.meis accessible - Check firewall rules
- Ensure Docker daemon is running
- Check logs:
docker-compose logsordocker logs ip-monitor - Verify
.envfile exists and has correct values
See LICENSE file for details.