1:环境配置
服务器:demo1 ip:192.168.75.100
2: 安装dhcp服务器
[root@demo1 ~]# yum -y install dhcp
[root@demo1 vsftpd]# cd /etc/dhcp/
[root@demo1 dhcp]# ll
总用量 8
drwxr-xr-x. 2 root root 23 11月 28 03:55 dhclient.d
drwxr-xr-x. 2 root root 28 11月 28 03:55 dhclient-exit-hooks.d
-rw-r--r-- 1 root root 120 4月 13 2018 dhcpd6.conf
-rw-r--r-- 1 root root 117 4月 13 2018 dhcpd.conf
drwxr-x--- 2 root dhcpd 28 1月 28 14:24 scripts
[root@demo1 dhcp]# cat dhcpd.conf
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
[root@demo1 dhcp]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example ./dhcpd.conf
cp:是否覆盖"./dhcpd.conf"? y
[root@demo1 dhcp]# cp dhcpd.conf dhcpd.conf.bak
[root@demo1 dhcp]# >dhcpd.conf
[root@demo1 dhcp]# vim dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option domain-name-servers 192.168.1.1 ;
option domain-name "demo.cn" ;
option routers 192.168.1.1 ;
option broadcast-address 192.168.1.255 ;
default-lease-time 600 ;
max-lease-time 7200 ;
next-server 192.168.1.10; #下一跳,下一个路由
filename "pxelinux.0"; #
}
[root@demo1 dhcp]# ifconfig ens37 192.168.1.10 netmask 255.255.255.0
[root@demo1 dhcp]# systemctl restart dhcpd