在 Debian 上通过 ISC DHCP Server(isc-dhcp-server) 配置多网段(多子网),主要有两种常见场景:
编辑 /etc/network/interfaces(或用 netplan,如果你用的是新版本)
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
auto eth0:1
iface eth0:1 inet static
address 192.168.2.1
netmask 255.255.255.0
重启网络:
systemctl restart networking
编辑 /etc/dhcp/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8;
}
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.100 192.168.2.200;
option routers 192.168.2.1;
option domain-name-servers 8.8.8.8;
}
编辑 /etc/default/isc-dhcp-server
INTERFACESv4="eth0"
启动服务:
systemctl restart isc-dhcp-server
✅ 适合:单臂路由 / 交换机 VLAN 共用口
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
auto eth1
iface eth1 inet static
address 10.0.0.1
netmask 255.255.255.0
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
}
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.100 10.0.0.200;
option routers 10.0.0.1;
}
INTERFACESv4="eth0 eth1"
systemctl restart isc-dhcp-server
✅ 适合:物理隔离网络
如果网段是通过 VLAN 划分的:
ip link add link eth0 name eth0.10 type vlan id 10
ip addr add 192.168.10.1/24 dev eth0.10
ip link set eth0.10 up
eth0.10dhcpd.conf 中配置对应 subnetjournalctl -u isc-dhcp-server
cat /var/lib/dhcp/dhcpd.leases
常见错误:
如果你能说明:
我可以给你更精确的配置示例。