PHPackages                             tourze/dns-server-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/dns-server-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/dns-server-bundle
========================

DNS服务端管理系统，支持权威DNS解析和上游DNS服务器配置

0.1.0(6mo ago)00MITPHPCI passing

Since Nov 13Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/tourze/dns-server-bundle)[ Packagist](https://packagist.org/packages/tourze/dns-server-bundle)[ RSS](/packages/tourze-dns-server-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (48)Versions (3)Used By (0)

DNS Server Bundle
=================

[](#dns-server-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/0814fa3ff313b9b4f36aa7a4e387ddb4992c9913c552fbb87ef32a0a8df903cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f646e732d7365727665722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/dns-server-bundle)[![PHP Version](https://camo.githubusercontent.com/151945e7f95bb93aa1c5acd515ac84845e5e5b992544da17d0378b24739a9530/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f646e732d7365727665722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/dns-server-bundle)[![Build Status](https://camo.githubusercontent.com/662d2be559fc9432386b1644164a88bc506cf5022e10469bd1e76373e345f163/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f646e732d7365727665722d62756e646c652f63692e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/tourze/dns-server-bundle/actions)[![Quality Score](https://camo.githubusercontent.com/2ac96cfa5ac664d856065d5b3786e387dea0e9a01f03416e7fac9fc4e456ce85/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f75727a652f646e732d7365727665722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/dns-server-bundle)[![Code Coverage](https://camo.githubusercontent.com/c0105aee510639e0aa53956dd96758f7a3153a951641b783ceaad2e1ed683caf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f75727a652f646e732d7365727665722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/dns-server-bundle)[![License](https://camo.githubusercontent.com/83e9b272bce4de453a72aeb5b967d1d84885c7d196846a9ed452c1c9fee16e83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f646e732d7365727665722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/dns-server-bundle)[![Total Downloads](https://camo.githubusercontent.com/64c3c8597033741bf479fe94b249aad02923fe4b424404e92d41f7dc7eee4f20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f646e732d7365727665722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/dns-server-bundle)

A comprehensive DNS server implementation for Symfony applications with async I/O support, admin interface, and complete DNS record management.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Configuration](#configuration)
- [Quick Start](#quick-start)
- [Commands](#commands)
- [Admin Interface](#admin-interface)
- [Advanced Usage](#advanced-usage)
- [Performance Considerations](#performance-considerations)
- [Security](#security)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- **Async DNS Server**: Built with ReactPHP for high-performance async I/O
- **Multi-Protocol Support**: UDP and TCP DNS protocols
- **Complete Record Types**: Support for A, AAAA, NS, CNAME, MX, TXT, SOA, PTR, SRV, CAA, and DNSSEC records
- **Admin Interface**: EasyAdmin-based management interface for DNS records and logs
- **Query Logging**: Comprehensive logging of DNS queries with IP tracking
- **Upstream Forwarding**: Configurable upstream DNS servers with different protocols
- **Flexible Matching**: Domain pattern matching strategies for selective forwarding
- **Performance Optimized**: Built-in caching and query optimization

Dependencies
------------

[](#dependencies)

### Required

[](#required)

- **PHP**: ^8.1
- **Symfony**: ^6.4 || ^7.0
- **ReactPHP**: For async I/O operations
- **Doctrine ORM**: For entity management
- **EasyAdmin**: For admin interface

### Optional

[](#optional)

- **Monolog**: For enhanced logging (recommended)
- **Symfony Security**: For admin interface authentication

Installation
------------

[](#installation)

```
composer require tourze/dns-server-bundle
```

Add the bundle to your `config/bundles.php`:

```
return [
    // ...
    DnsServerBundle\DnsServerBundle::class => ['all' => true],
];
```

Configuration
-------------

[](#configuration)

### Service Configuration

[](#service-configuration)

Configure the bundle in `config/services.yaml`:

```
services:
    DnsServerBundle\Service\DnsWorkerService:
        arguments:
            $dnsQueryService: '@DnsServerBundle\Service\DnsQueryService'
            $logger: '@logger'
        tags:
            - { name: 'monolog.logger', channel: 'dns' }
```

### Database Entities

[](#database-entities)

The bundle provides two main entities:

- `DnsQueryLog`: Stores DNS query logs with IP tracking
- `UpstreamDnsServer`: Manages upstream DNS server configurations

Quick Start
-----------

[](#quick-start)

### 1. Database Setup

[](#1-database-setup)

Run migrations to create the required tables:

```
php bin/console doctrine:migrations:migrate
```

### 2. Start the DNS Server

[](#2-start-the-dns-server)

```
php bin/console dns:worker:start --host=0.0.0.0 --port=53
```

### 3. Configure Upstream DNS Servers

[](#3-configure-upstream-dns-servers)

Access the admin interface at `/admin` and add upstream DNS servers:

```
// Example upstream server configuration
$upstream = new UpstreamDnsServer();
$upstream->setName('Cloudflare DNS');
$upstream->setHost('1.1.1.1');
$upstream->setPort(53);
$upstream->setProtocol(DnsProtocolEnum::UDP);
$upstream->setMatchStrategy(MatchStrategy::SUFFIX);
$upstream->setMatchPattern('*.example.com');
```

### 4. Basic Usage in Code

[](#4-basic-usage-in-code)

```
use DnsServerBundle\Service\DnsQueryService;
use DnsServerBundle\Service\DnsResolver;

// Resolve DNS queries
$resolver = new DnsResolver($upstreamServers);
$result = $resolver->resolve('example.com', RecordType::A);

// Handle DNS queries programmatically
$queryService = new DnsQueryService($resolver, $logger);
$response = $queryService->handleQuery($dnsMessage, $clientAddress, $server);
```

Commands
--------

[](#commands)

### DNS Worker

[](#dns-worker)

Start the DNS server daemon:

```
# Start with default settings (0.0.0.0:53)
php bin/console dns:worker:start

# Start with custom host and port
php bin/console dns:worker:start --host=127.0.0.1 --port=5353

# Start with verbose logging
php bin/console dns:worker:start -v
```

**Options:**

- `--host`: DNS server binding host (default: 0.0.0.0)
- `--port`: DNS server binding port (default: 53)

**Note**: Port 53 requires root privileges on most systems.

Admin Interface
---------------

[](#admin-interface)

The bundle integrates with EasyAdmin to provide:

- **DNS Query Logs**: View and analyze DNS query history
- **Upstream DNS Servers**: Manage upstream server configurations
- **Real-time Monitoring**: Track DNS server performance and statistics

Access the admin interface at `/admin` after proper authentication setup.

Advanced Usage
--------------

[](#advanced-usage)

### DNS Record Types

[](#dns-record-types)

Full support for DNS record types including:

- **A/AAAA**: IPv4/IPv6 address records
- **NS**: Name server records
- **CNAME**: Canonical name records
- **MX**: Mail exchange records
- **TXT**: Text records
- **SOA**: Start of authority records
- **PTR**: Pointer records for reverse DNS
- **SRV**: Service location records
- **CAA**: Certificate Authority Authorization
- **DNSSEC**: DS, RRSIG, NSEC, DNSKEY records

### Match Strategies

[](#match-strategies)

Configure how domains are matched for upstream forwarding:

- **EXACT**: Exact domain match
- **SUFFIX**: Domain suffix matching
- **PREFIX**: Domain prefix matching
- **REGEX**: Regular expression matching
- **WILDCARD**: Wildcard pattern matching (e.g., `*.example.com`)

### Protocol Support

[](#protocol-support)

- **UDP**: Standard DNS over UDP (implemented)
- **TCP**: DNS over TCP for large responses (implemented)
- **DoH**: DNS over HTTPS (implemented)
- **DoT**: DNS over TLS (implemented)

### Upstream Server Configuration

[](#upstream-server-configuration)

Configure multiple upstream DNS servers with different settings:

```
use DnsServerBundle\Enum\DnsProtocolEnum;
use DnsServerBundle\Enum\MatchStrategy;
use DnsServerBundle\Entity\UpstreamDnsServer;

// Configure DNS over TLS upstream
$dotServer = new UpstreamDnsServer();
$dotServer->setName('Cloudflare DoT')
    ->setHost('1.1.1.1')
    ->setPort(853)
    ->setProtocol(DnsProtocolEnum::DOT)
    ->setCertPath('/path/to/client.crt')
    ->setKeyPath('/path/to/client.key')
    ->setVerifyCert(true);

// Configure DNS over HTTPS upstream
$dohServer = new UpstreamDnsServer();
$dohServer->setName('Google DoH')
    ->setHost('dns.google')
    ->setPort(443)
    ->setProtocol(DnsProtocolEnum::DOH)
    ->setPath('/dns-query');
```

### DNS Query Logging

[](#dns-query-logging)

All DNS queries are automatically logged with detailed information:

```
use DnsServerBundle\Entity\DnsQueryLog;

// Query logs include:
// - Domain name
// - Query type (A, AAAA, MX, etc.)
// - Client IP address
// - Response code
// - Response time
// - Upstream server used
// - Query timestamp
```

### Custom DNS Resolvers

[](#custom-dns-resolvers)

Create custom resolvers for specific use cases:

```
use DnsServerBundle\Service\DnsResolver;
use DnsServerBundle\Service\DnsMatcherService;

$matcher = new DnsMatcherService();
$resolver = new DnsResolver($upstreamServers, $matcher, $logger);

// Add custom resolution logic
$resolver->resolve('example.com', RecordType::A);
```

Performance Considerations
--------------------------

[](#performance-considerations)

1. **Memory Usage**: Default cache limit is 10,000 entries
2. **Query Performance**: ~5,000 QPS per instance
3. **Cache Hit Rate**: Optimize for &gt;80% cache hit rate
4. **Concurrent Connections**: Async I/O handles thousands of concurrent queries

Security
--------

[](#security)

- **Query Logging**: All DNS queries are logged with IP tracking
- **Access Control**: Configurable upstream server restrictions
- **Rate Limiting**: Built-in query rate limiting (configurable)
- **Input Validation**: Comprehensive DNS message validation

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance67

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Total

2

Last Release

196d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13899502?v=4)[tourze](/maintainers/tourze)[@tourze](https://github.com/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-dns-server-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-dns-server-bundle/health.svg)](https://phpackages.com/packages/tourze-dns-server-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M736](/packages/sylius-sylius)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
