Linux CentOS DHCP服务器搭建

1.DHCP作用及原理

DHCP原理及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;
}


DHCP相关文章链接

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山水牧羊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值