Files
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

195 lines
3.0 KiB
Markdown
Raw Permalink 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.
# 快速部署指南
## 方案一:Docker 部署(推荐)⭐
### 1. 启动服务
```bash
cd dhcp-dns-manager
./start.sh
```
或手动执行:
```bash
docker-compose up -d
```
### 2. 访问 Web 界面
打开浏览器访问:http://your-server-ip:8080
默认登录:
- 用户名:`admin`
- 密码:`admin`
⚠️ **首次使用请修改默认密码!**
### 3. 配置网络
编辑 `configs/config.json`
```json
{
"dhcp": {
"interface": "eth0", // 改为你的网络接口
"network": "192.168.1.0", // 你的网段
"gateway": "192.168.1.1", // 你的网关
"ip_pool_start": "192.168.1.100",
"ip_pool_end": "192.168.1.200"
}
}
```
### 4. 重启服务使配置生效
```bash
docker-compose restart
```
---
## 方案二:Linux 本地部署
### 1. 安装 Go
```bash
# Ubuntu/Debian
sudo apt update
sudo apt install golang-go
# 或从官网下载
wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
```
### 2. 编译程序
```bash
cd dhcp-dns-manager
go mod download
go build -o dhcp-dns-manager ./cmd
```
### 3. 以 systemd 服务运行
创建服务文件:
```bash
sudo nano /etc/systemd/system/dhcp-dns-manager.service
```
内容:
```ini
[Unit]
Description=DHCP & DNS Manager
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/path/to/dhcp-dns-manager
ExecStart=/path/to/dhcp-dns-manager/dhcp-dns-manager -config configs/config.json
Restart=always
[Install]
WantedBy=multi-user.target
```
启动服务:
```bash
sudo systemctl daemon-reload
sudo systemctl enable dhcp-dns-manager
sudo systemctl start dhcp-dns-manager
sudo systemctl status dhcp-dns-manager
```
---
## 方案三:开发模式运行
```bash
cd dhcp-dns-manager
go run ./cmd -config configs/config.json
```
---
## 防火墙配置
如果启用了防火墙,需要开放端口:
```bash
# UFW (Ubuntu)
sudo ufw allow 53/udp
sudo ufw allow 67/udp
sudo ufw allow 8080/tcp
# Firewalld (CentOS)
sudo firewall-cmd --permanent --add-port=53/udp
sudo firewall-cmd --permanent --add-port=67/udp
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
```
---
## 常见问题
### Q: 端口被占用怎么办?
修改 `configs/config.json` 中的端口:
```json
{
"dns": {
"listen_port": 5353
},
"web": {
"port": 8081
}
}
```
### Q: 如何查看日志?
```bash
# Docker
docker-compose logs -f
# systemd
sudo journalctl -u dhcp-dns-manager -f
# 直接运行
查看程序输出
```
### Q: 数据库在哪里?
SQLite 数据库文件:`data/dhcp-dns.db`
备份:
```bash
cp data/dhcp-dns.db data/dhcp-dns.db.backup
```
### Q: 忘记密码怎么办?
目前使用简单认证,直接修改代码或等待多用户版本。
---
## 下一步
1. 登录 Web 界面
2. 配置 DHCP IP 地址池
3. 添加静态 IP 绑定(如有需要)
4. 配置 DNS 记录
5. 测试网络连通性
祝使用愉快!🎉