- 安装DHCP服务
yum install dhcpd
- 配置网卡
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=ens192
UUID=90858369-6dc6-4438-9b2f-407766400e24
DEVICE=ens192
ONBOOT=yes
IPADDR=192.168.230.3
NETMASK=255.255.255.0
GATEWAY=192.168.230.255
- 重启网络服务,检查
systemctl restart network.service
ip addr
- 部署DHCP
vi /etc/dhcp/dhcpd.conf
ddns-update-style interim;
subnet 192.168.230.0 netmask 255.255.255.0 {
range 192.168.230.80 192.168.230.199;
192.168.233.199 option routers 192.168.230.2;
default-lease-time 600;
max-lease-time 7200;
}
host client_83_ens192{
hardware ethernet 90:b1:1c:11:1d:01;
fixed-address 192.168.230.83;
}
- 启动DHCP服务
sytemctl start dhcpd.service
systemctl restart dhcpd.service
- 设置为开机自启动
systemctl enable dhcpd.service
- 如果双网卡可以进行网卡绑定,实现内外访问
将DHCP服务器绑定在"em2"网卡上
vim /etc/sysconfig/dhcpd, 末尾添加内容
DHCPDARGS="ens92"