mosdns/README-启动说明.md

2.5 KiB
Raw Blame History

🚀 快速启动说明

最简单的启动方式

# 一键启动
./start.sh

就这么简单!脚本会自动:

  1. 检查并编译程序(如果需要)
  2. 检查配置文件
  3. 检查必需的数据文件
  4. 启动 MosDNS 服务

启动后访问

Web 管理界面

http://localhost:5555

功能:

  • 📊 系统状态监控
  • 🎯 域名规则管理
  • 🔄 配置热加载(无需重启)
  • 📁 域名文件管理
  • 🔧 MikroTik 路由器配置

API 接口

# 查看服务器信息
curl http://localhost:8080/api/server/info

# 热加载配置
curl -X POST http://localhost:8080/api/config/reload

DNS 服务

# 测试 DNS 解析
dig @localhost baidu.com
dig @localhost google.com

配置文件说明

简单配置 (config.yaml)

  • 适合开发测试
  • 包含所有核心功能
  • 开箱即用

生产配置 (config-production.yaml)

  • 性能优化
  • 日志完善
  • 缓存持久化
  • 安全加固

使用生产配置:

./dist/mosdns-linux-amd64 start -c config-production.yaml

常用操作

启动服务

./start.sh
# 或
./dist/mosdns-linux-amd64 start -c config.yaml

后台运行

nohup ./start.sh > mosdns.log 2>&1 &

热加载配置(无需重启)

# 修改配置文件后
curl -X POST http://localhost:5555/api/config/reload

查看日志

tail -f mosdns.log

停止服务

pkill mosdns
# 或
kill $(pidof mosdns)

故障排查

端口被占用

# 检查端口占用
sudo netstat -tulpn | grep -E ':53|:5555|:8080'

# 修改配置文件中的端口
vim config.yaml

权限不足53 端口)

# 方法 1: 使用 sudo 启动
sudo ./start.sh

# 方法 2: 赋予绑定权限
sudo setcap cap_net_bind_service=+ep dist/mosdns-linux-amd64

# 方法 3: 修改为非特权端口
# 编辑 config.yaml将 53 改为 5353

Web 界面无法访问

# 检查防火墙
sudo ufw allow 5555/tcp

# 或检查监听
sudo netstat -tulpn | grep 5555

更多信息

详细文档请查看:


💡 提示: 首次启动后,访问 http://localhost:5555 即可通过 Web 界面管理所有配置!