mosdns/README-启动说明.md

148 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🚀 快速启动说明
## 最简单的启动方式
```bash
# 一键启动
./start.sh
```
就这么简单!脚本会自动:
1. ✅ 检查并编译程序(如果需要)
2. ✅ 检查配置文件
3. ✅ 检查必需的数据文件
4. ✅ 启动 MosDNS 服务
---
## 启动后访问
### Web 管理界面
```
http://localhost:5555
```
**功能**:
- 📊 系统状态监控
- 🎯 域名规则管理
- 🔄 配置热加载(无需重启)
- 📁 域名文件管理
- 🔧 MikroTik 路由器配置
### API 接口
```bash
# 查看服务器信息
curl http://localhost:8080/api/server/info
# 热加载配置
curl -X POST http://localhost:8080/api/config/reload
```
### DNS 服务
```bash
# 测试 DNS 解析
dig @localhost baidu.com
dig @localhost google.com
```
---
## 配置文件说明
### 简单配置 (`config.yaml`)
- ✅ 适合开发测试
- ✅ 包含所有核心功能
- ✅ 开箱即用
### 生产配置 (`config-production.yaml`)
- ✅ 性能优化
- ✅ 日志完善
- ✅ 缓存持久化
- ✅ 安全加固
**使用生产配置**:
```bash
./dist/mosdns-linux-amd64 start -c config-production.yaml
```
---
## 常用操作
### 启动服务
```bash
./start.sh
# 或
./dist/mosdns-linux-amd64 start -c config.yaml
```
### 后台运行
```bash
nohup ./start.sh > mosdns.log 2>&1 &
```
### 热加载配置(无需重启)
```bash
# 修改配置文件后
curl -X POST http://localhost:5555/api/config/reload
```
### 查看日志
```bash
tail -f mosdns.log
```
### 停止服务
```bash
pkill mosdns
# 或
kill $(pidof mosdns)
```
---
## 故障排查
### 端口被占用
```bash
# 检查端口占用
sudo netstat -tulpn | grep -E ':53|:5555|:8080'
# 修改配置文件中的端口
vim config.yaml
```
### 权限不足53 端口)
```bash
# 方法 1: 使用 sudo 启动
sudo ./start.sh
# 方法 2: 赋予绑定权限
sudo setcap cap_net_bind_service=+ep dist/mosdns-linux-amd64
# 方法 3: 修改为非特权端口
# 编辑 config.yaml将 53 改为 5353
```
### Web 界面无法访问
```bash
# 检查防火墙
sudo ufw allow 5555/tcp
# 或检查监听
sudo netstat -tulpn | grep 5555
```
---
## 更多信息
详细文档请查看:
- 📖 [启动指南.md](./启动指南.md) - 完整启动文档
- 📖 [YLTX-DNS智能防污染系统-二次开发总结.md](./YLTX-DNS智能防污染系统-二次开发总结.md) - 功能说明
- 📖 [构建脚本使用说明.md](./构建脚本使用说明.md) - 编译说明
---
**💡 提示**: 首次启动后,访问 http://localhost:5555 即可通过 Web 界面管理所有配置!