在 Linux 上配置 DHCP 地址保留(Reserved IP / Static Reservation),通常取决于你使用的 DHCP 服务软件。最常见的是 ISC DHCP Server(dhcpd),下面以它为主说明。
# Debian / Ubuntu
apt install isc-dhcp-server
# CentOS / RHEL
yum install dhcp
一般路径:
/etc/dhcp/dhcpd.conf
根据 MAC 地址 绑定固定 IP:
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;
}
host server01 {
hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.1.50;
}
说明:
hardware ethernet:客户端 MAC 地址fixed-address:要保留的 IP(不能在 range 内)systemctl restart isc-dhcp-server
# 或
systemctl restart dhcpd
arp -a
# 或
ip neigh
/etc/dnsmasq.conf
dhcp-host=00:11:22:33:44:55,192.168.1.50
或带主机名:
dhcp-host=00:11:22:33:44:55,server01,192.168.1.50
重启:
systemctl restart dnsmasq
"reservations": [
{
"hw-address": "00:11:22:33:44:55",
"ip-address": "192.168.1.50"
}
]
✅ 保留 IP 不要写在 range 里
✅ MAC 地址格式要正确(冒号分隔)
✅ 客户端需重新获取 IP(重启网络或 dhclient -r)
如果你能告诉我:
我可以给你精确配置文件示例。