CentOS8DHCP单作用域配置
2025-05-16 18:39阅读:
CentOS 8
DHCP单作用域配置
主网卡ens192:172.16.35.128/24(子网A)
1. 安装DHCP服务
Rpm -q
dhcp-server
dnf install -y dhcp-server
systemctl start dhcpd
systemctl enable dhcpd
2. 主配置文件修改
编辑/etc/dhcp/dhcpd.conf
:
option domain-name 'example.com';
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet
172.16.35.0 netmask 255.255.255.0
{
range 172.16.35.100
172.16.35.200;
option
domain-name-servers ns1.internal.example.org;
option domain-name
'internal.example.org';
option routers
172.16.35.2;
option domain-name-servers 8.8.8.8;
option
broadcast-address 172.16.35.255;
default-lease-time
600;
max-lease-time
7200;
}
host abc {
hardware ethernet
00:50:56:c0:00:08;
fixed-address
172.16.35.129;
}
3. 防火墙配置
firewall-cmd --add-service=dhcp --permanent
firewall-cmd --reload
4.(设置selinux宽松模式)
setenforce 0
5.
服务启动
systemctl restart
dhcpd(配置文件一旦发生变化,想生效,必须执行此命令)
服务启动失败:通过dhcpd
-t测试配置文件语法
4. 服务验证
客户端未Windows
命令提示符下查看
Ipconfig/all(查看)
Ipconfig/release(释放)
Ipconfig/renew(重新获得)
图形模式下查看