可以的。Debian 可以作为 DHCP 中继(DHCP Relay / DHCP Helper)使用,通常通过 isc-dhcp-relay(或新一点的环境中用 dhcp-helper、kea-dhcp4 中继等)来实现。
下面给你几种常见做法。
sudo apt update
sudo apt install isc-dhcp-relay
编辑配置文件:
sudo nano /etc/default/isc-dhcp-relay
示例内容:
# 监听的网卡(客户端所在网段)
INTERFACES="eth0"
# DHCP 服务器地址
SERVERS="192.168.10.100"
# 可选:本机作为中继的源地址
OPTIONS="-a"
说明:
eth0:连接客户端网络的网卡192.168.10.100:真正的 DHCP Server IPsudo systemctl enable isc-dhcp-relay
sudo systemctl start isc-dhcp-relay
确保 UDP 67 / 68 放行:
sudo ufw allow 67/udp
sudo ufw allow 68/udp
sudo apt install dhcp-helper
配置 /etc/default/dhcp-helper:
DHCPHELPER_OPTS="-b eth0 -s 192.168.10.100"
启动:
sudo systemctl enable dhcp-helper
sudo systemctl start dhcp-helper
Debian 本身不会自动做 DHCP 中继,只开 ip_forward 是不够的,因为 DHCP 是广播协议,必须靠中继代理转发。
客户端网段
192.168.1.0/24
|
Debian(中继)
|
192.168.10.100(DHCP Server)
Debian 收到 192.168.1.x 的 DHCP 请求后,转发给 192.168.10.100,并带上 giaddr。
在 Debian 上抓包:
sudo tcpdump -i eth0 port 67 or port 68
看到:
说明中继正常。
如果你愿意,可以告诉我:
我可以直接帮你写一份可用配置。