Skip to content

dtsypkin/DNS-Check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

DNS Check

A Python utility to monitor domain DNS A records and send notifications when IP addresses change. Supports email and Telegram notifications.

Features

  • DNS Monitoring: Continuously monitors a domain's A record (IPv4 address)
  • Change Detection: Automatically detects when a domain's IP address changes
  • Email Notifications: Send alerts via SMTP email
  • Telegram Notifications: Send alerts via Telegram bot API
  • IP History: Stores the last known IP address locally

Requirements

  • Python 3.x
  • dnspython: For DNS resolution
  • requests: For Telegram API calls

Installation

  1. Clone the repository:
git clone https://github.com/dtsypkin/DNS-Check.git
cd DNS-Check
  1. Install dependencies:
pip install dnspython requests

Configuration

Edit dns_check.py and set the following variables:

General Settings

  • NOTIFICATION_METHOD: Choose 'email' or 'telegram'
  • DOMAIN_TO_MONITOR: The domain to monitor (e.g., example.com)

Email Configuration

  • RECIPIENT_EMAIL: Email address to receive notifications
  • SENDER_EMAIL: Email address sending notifications
  • SMTP_SERVER: SMTP server address (e.g., smtp.gmail.com)
  • SMTP_PORT: SMTP port (default: 587)
  • SMTP_PASSWORD: Password for the sender's email account

Telegram Configuration

  • TELEGRAM_BOT_TOKEN: Your Telegram bot token
  • TELEGRAM_CHAT_ID: Your Telegram chat ID

Usage

Run the script:

python dns_check.py

For continuous monitoring, set up a cron job (Linux/Mac) or Task Scheduler (Windows):

Cron Example (Every hour)

0 * * * * cd /path/to/DNS-Check-1 && python dns_check.py

How It Works

  1. Resolves the DNS A record for the specified domain
  2. Compares the current IP with the previously stored IP (in last_ip.txt)
  3. If different, sends a notification with the old and new IP addresses
  4. Updates the stored IP address

Output Files

  • last_ip.txt: Stores the last known IP address of the monitored domain

License

MIT License

Support

For issues or questions, please create an issue on GitHub.

About

Personal script for checking changes in DNS resolvers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages