Files
dhcp-dns-manager/QUICKSTART.md
T
CNBUGS AI 8ad4c3576d Fix DHCP client unable to get IP and config not persisting
- Fixed verifyAssignment being too strict for new clients
- Fixed parseRequestedIP string conversion bug
- Fixed response sent to 0.0.0.0 instead of broadcast address
- Added SO_BROADCAST support for UDP socket
- Fixed session persistence after page refresh (localStorage)
- Added in-memory session store for auth middleware
- Added config reloader so DHCP server picks up web UI changes dynamically
2026-04-24 16:03:54 +08:00

316 wiersze
4.7 KiB
Markdown

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.
# 🚀 快速开始指南
选择你的操作系统开始部署:
---
## 🐧 Linux 系统
### 方法 1:一键安装脚本(推荐)
```bash
# 下载项目
git clone <your-repo-url>
cd dhcp-dns-manager
# 运行安装脚本(需要 root 权限)
sudo ./install.sh
```
安装完成后:
- ✅ 自动配置 systemd 服务
- ✅ 自动配置防火墙
- ✅ 自动启动服务
**访问**: http://your-server-ip:8080
**账号**: `admin` / `admin`
### 方法 2Docker 部署
```bash
docker-compose up -d
```
### 方法 3:手动运行
```bash
go mod download
go run ./cmd -config configs/config.json
```
---
## 🪟 Windows 系统
### 方法 1Docker Desktop(推荐)
1. 安装 Docker Desktop: https://www.docker.com/products/docker-desktop
2. 双击运行 `start.bat`
3. 访问 http://localhost:8080
### 方法 2:本地运行
1. 安装 Go: https://golang.org/dl/
2. 双击运行 `start.bat`
3. 访问 http://localhost:8080
### 方法 3WSL2
在 WSL2 中按照 Linux 方法部署
---
## 🍎 macOS 系统
```bash
# 安装 Go
brew install go
# 运行
go mod download
go run ./cmd -config configs/config.json
```
---
## 📦 Docker(所有平台通用)
```bash
# 启动
docker-compose up -d
# 查看日志
docker-compose logs -f
# 停止
docker-compose down
# 重启
docker-compose restart
```
---
## ✅ 验证安装
### 1. 检查服务状态
**Linux:**
```bash
systemctl status dhcp-dns-manager
```
**Windows:**
```powershell
sc query dhcp-dns-manager
```
**Docker:**
```bash
docker-compose ps
```
### 2. 访问 Web 界面
浏览器打开:http://localhost:8080
看到登录页面即表示安装成功!
### 3. 测试 API
```bash
curl http://localhost:8080/api/dashboard
```
---
## 🔧 配置说明
编辑 `configs/config.json`
```json
{
"dhcp": {
"enabled": true,
"interface": "eth0", // Linux: eth0, Windows: "以太网"
"network": "192.168.1.0",
"ip_pool_start": "192.168.1.100",
"ip_pool_end": "192.168.1.200"
},
"dns": {
"enabled": true,
"listen_port": 53,
"upstream": ["8.8.8.8", "1.1.1.1"]
},
"web": {
"port": 8080
}
}
```
---
## 🔐 安全建议
### 首次使用必做:
1. **修改默认密码**
- 登录 Web 界面
- 进入设置 → 修改密码
2. **限制访问 IP**(可选)
在防火墙中限制只允许内网访问:
```bash
# Linux UFW
sudo ufw allow from 192.168.1.0/24 to any port 8080
```
3. **启用 HTTPS**(生产环境)
使用 Nginx 反向代理:
```nginx
server {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:8080;
}
}
```
---
## 📊 常用操作
### 查看日志
**Linux:**
```bash
# systemd 方式
journalctl -u dhcp-dns-manager -f
# Docker 方式
docker-compose logs -f
```
**Windows:**
```powershell
# Docker 方式
docker-compose logs -f
# 事件查看器
eventvwr.msc
```
### 备份数据
```bash
# 备份数据库
cp data/dhcp-dns.db data/dhcp-dns.db.backup.$(date +%Y%m%d)
# 备份配置
cp configs/config.json configs/config.json.backup
```
### 恢复数据
```bash
# 停止服务
systemctl stop dhcp-dns-manager
# 恢复数据库
cp data/dhcp-dns.db.backup data/dhcp-dns.db
# 启动服务
systemctl start dhcp-dns-manager
```
---
## ❓ 故障排查
### 问题 1:无法访问 Web 界面
**检查服务状态:**
```bash
# Linux
systemctl status dhcp-dns-manager
# Docker
docker-compose ps
# Windows
netstat -ano | findstr :8080
```
**检查防火墙:**
```bash
# Linux
sudo ufw status
# Windows
Get-NetFirewallRule | Where-Object Enabled -eq True
```
### 问题 2:端口被占用
**查找占用进程:**
```bash
# Linux
sudo lsof -i :8080
sudo netstat -tulpn | grep :8080
# Windows
netstat -ano | findstr :8080
```
**解决方案:**
1. 停止占用端口的服务
2. 或修改 `config.json` 使用其他端口
### 问题 3DHCP/DNS 无法启动
**检查权限:**
```bash
# Linux - 需要 root 权限绑定 53/67 端口
sudo systemctl restart dhcp-dns-manager
# Docker - 确保使用 network_mode: host
```
**检查端口占用:**
```bash
sudo netstat -ulpn | grep :53
sudo netstat -ulpn | grep :67
```
---
## 📚 更多文档
- [部署指南](DEPLOY.md) - 详细部署步骤
- [Windows 指南](WINDOWS_GUIDE.md) - Windows 专属部署
- [API 示例](API_EXAMPLES.md) - API 接口测试
- [使用场景](USE_CASES.md) - 实际应用案例
- [项目总结](PROJECT_SUMMARY.md) - 功能清单
---
## 🆘 获取帮助
1. 查看日志定位问题
2. 检查配置文件语法
3. 确认防火墙设置
4. 提交 Issue 反馈
---
**祝你使用愉快!** 🎉
有任何问题随时反馈!