Linux CentOS DHCP安装 部署 配置
1.DHCP作用及原理
2.相关配置
- 端口 udp67 udp68
- 端服务 dhcpd dhrelay
- 配置文件: /etc/dhcp/dhcpd.conf
- 中继文件: /etc/sysconfig/dhcrealy
3.安装
yum install -y dhcp
4.配置
cat /etc/dhcp/dhcpd.conf
#此处仅展示最简配置
subnet 192.168.130.0 netmask 255.255.255.0 {
range 192.168.130.70 192.168.130.100;
option routers 192.168.130.0;
default-lease-time 600;
max-lease-time 7200;
}
4.1.配置文件额外说明
在使用PXE时,需要通过DHCP指定客户端从何处获取引导文件,及引导文件名称,需要在配置文件dhcpd.conf增加如下节点。
filename "pxelinux.0"; #引导系统启动文件
next-server 192.168.130.100; #tftp server
如何使用PXE批量部署系统,请参考
Linux 使用dhcp tftp httpd组件pxe 批量部署系统(暂未补充)
5.配置语法检查
dhcpd -cf /etc/dhcp/dhcpd.conf
6.启动
systemctl start dhcpd
附 配置文件详解
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...(定义全局配置)
option domain-name "example.org"; #用来定义客户端所属的域环境
option domain-name-servers ns1.example.org, ns2.example.org; #DNS服务器的主机名或IP
default-lease-time 600;#租约期限,单位是秒
max-lease-time 7200;#最大租约时间
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;#日志类型,日志类型是local7
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
#subnet 网络 nemtmask 子网掩码 {
#选项或参数
}
# This is a very basic subnet declaration. #需要写基本的一些内容 如网段、子网、地址池
subnet 10.254.239.0 netmask 255.255.255.224 {
range 10.254.239.10 10.254.239.20;
option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;#网关
}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
subnet 10.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 10.254.239.40 10.254.239.60;
option broadcast-address 10.254.239.31;
option routers rtr-239-32-1.example.org;
}