NextDNS 是一个开源的 DNS 管理工具,支持 DNS-over-HTTPS 和 DNS-over-TLS。以下是 NextDNS 的安装指南
环境要求
- 操作系统:Linux(推荐 Ubuntu/Debian 或 CentOS)
- Python 版本:Python 3.6 或更高版本
- 域名:需要至少一个域名,并已完成 IANA 准备(ARPA 或其他管理机构)
安装 NextDNS
-
下载 NextDNS
wget https://github.com/nextdns/nextdns/releases/download/v1../nextdns-1...tar.gz
或者通过 pip 安装:
pip install nextdns
-
解压并进入目录
tar -xzf nextdns-1...tar.gz cd nextdns-1..
-
安装依赖
apt-get install -y python3 python3-dev build-essential
配置数据库
NextDNS 支持 MySQL 和 PostgreSQL,以下使用 MySQL 为例:
-
安装数据库
apt-get install -y mysql-server mysql-client
启动并登录 MySQL:
systemctl start mysql mysql -u root -p
-
创建数据库和用户
CREATE DATABASE IF NOT EXISTS nextdns; CREATE USER 'nextdns'@'localhost' IDENTIFIED BY 'yourpassword'; GRANT ALL PRIVILEGES ON nextdns.* TO 'nextdns'@'localhost'; FLUSH PRIVILEGES;
-
初始化数据库
./nextdns init --driver=mysql --db-host=localhost --db-name=nextdns --db-user=nextdns --db-pass=yourpassword
迁移数据库
-
下载迁移脚本
wget https://raw.githubusercontent.com/nextdns/nextdns/master/migration/nextdns.sql
-
执行迁移脚本
mysql -u root -p < nextdns.sql
创建管理员账号
运行 NextDNS 服务:
./nextdns serve --config-file=nextdns.conf
打开浏览器,访问 http://localhost:808,创建管理员账号。
启动服务
将 NextDNS 服务添加到系统启动时加载:
cp nextdns.service ~/.config/systemd/user/ systemctl link --no-ask-next /etc/systemd/user/nextdns.service systemctl enable --now nextdns.service
配置 DNS 服务器
编辑 nextdns.conf 文件:
vim nextdns.conf
配置如下:
listen=127...1:53 resolver=127...1:53 database: driver: mysql host: localhost name: nextdns user: nextdns password: yourpassword
防火墙配置
确保防火墙开放以下端口:
iptables -A INPUT -p tcp --dport 53 -j ACCEPT iptables -A INPUT -p tcp --dport 808 -j ACCEPT
启动 DNS-over-TLS/HTTPS
访问 http://localhost:808,登录管理员账号,配置 DNS 记录和 TLS/HTTPS 服务。
测试 DNS 查询
使用 nslookup 或 dig 检查 DNS 解析:
dig @localhost nextdns.example.com
管理界面
访问 http://localhost:808/ui,管理域名、记录和 DNSSEC。
注意事项
- 域名备案:确保你的域名已在 IANA 注册。
- DNSSEC:建议启用 DNSSEC 来保护 DNS 解析。
- 性能优化:根据需求调整解析记录和缓存策略。
完成以上步骤后,你应该能够成功搭建并使用 NextDNS 服务器。

如果没有特点说明,本站所有内容均由原子加速器官方网站|提供客户端版本、线路管理与节点选择功能,适配Windows、Android、iOS等设备,便于用户进行网络连接优化原创,转载请注明出处!