Mikrotik Technitium DNS

Mikrotik DHCP to DNS (Technitium DNS)

Short description

This article highlights a solution for automating DNS and PTR record management using Technitium DNS and MikroTik scripting. It details how a custom MikroTik script dynamically adds DNS and PTR records for new DHCP clients and removes them upon lease expiration. The script leverages Technitium DNS's API, synchronizing changes across multiple DNS nodes to ensure centralized management and failover capabilities in a multi-network setup. Perfect for those seeking a streamlined and automated approach to DNS management in homelabs or advanced network environments.

For the past month, I’ve been experimenting with Technitium DNS in my homelab, and I must say it’s an incredibly powerful and user-friendly DNS system. With built-in support for the latest technologies, such as DNS over HTTPS (DoH) and blacklists, Technitium DNS has proven to be a versatile and reliable solution for my network needs. I’ve deployed it as a central DNS server across several interconnected networks, replacing a previous decentralized approach.

Intro

Technitium DNS is a modern, feature-rich DNS server solution that supports centralized management, advanced DNS technologies, and seamless automation, making it ideal for both homelabs and enterprise networks.

Previously, in each network, the primary router (usually MikroTik) assigned static DNS entries for clients via DHCP leases. While this worked, it was far from an ideal solution. The setup was not centralized and lacked failover capability; if the networks became disconnected, the DNS server for a given segment became inaccessible. To address these shortcomings, I implemented a centralized DNS system using Technitium DNS with multiple nodes and a primary master node that synchronizes records across all other nodes. This setup ensures high availability and redundancy.

One of the standout features of Technitium DNS is its integrated web administration tool. Built using modern web technologies, the interface is clean, intuitive, and professional, making it easy to configure and manage DNS records. I found this particularly appealing as it streamlines the management of complex DNS setups without sacrificing functionality.

However, one challenge I faced was automating DNS and PTR record creation for new DHCP clients. To solve this, I leveraged MikroTik’s scripting capabilities. Using scripts, I configured the MikroTik routers to send API requests to the Technitium master DNS server whenever a new client connects to the network and receives an IP lease. The API request automatically creates corresponding DNS “A” and PTR records. These records are then synchronized across all Technitium DNS nodes, ensuring all network segments are updated with the latest information.

Each MikroTik router in the network is configured with a unique DNS prefix, allowing precise identification of which network a client belongs to based on its PTR record. This setup has been instrumental in maintaining order and clarity in my multi-network environment.

I’ve decided to share the MikroTik script I developed, as it might be useful to others facing similar challenges. The script not only adds DNS records for new leases but also removes them when a lease expires. This dynamic handling of DNS records ensures that the system remains clean and up-to-date without manual intervention.

Key Benefits of Using Technitium DNS in My Setup:

  • Centralized DNS Management: Simplifies administration by consolidating DNS records across multiple network segments.
  • High Availability: Multiple nodes ensure failover capability, keeping the DNS system operational even during network disruptions.
  • Modern Web Interface: Easy-to-use and professional-grade interface for efficient DNS management.
  • Automation-Friendly: Supports API integration, enabling dynamic DNS record creation via scripts.
  • Customizable and Scalable: Ideal for small homelabs and large network environments alike.

If you’re looking for a centralized DNS solution with modern features and excellent automation support, I highly recommend giving Technitium DNS a try. The addition of automation scripts, like the one I’ve created, can further enhance its utility and make it a cornerstone of your network infrastructure.

Script

Github source

Created on: December 31, 2024

Last modified: December 31, 2024, 8:49 am