Is your DHCP Server Authoritative?

本文探讨了ISCDHCP服务器中'authoritative'指令的重要性及其配置方法。当DHCP服务器作为网络上的唯一授权服务器时,该指令对于拒绝不合理地址请求至关重要。文章还介绍了如何通过配置拒绝来处理迁移过程中旧地址池的问题。

Possibly the single most annoying misconfiguration of the ISC DHCP Server today is forgetting to set the 'authoritative;' directive, when doing so is appropriate.

When a DHCP server believes that a client is requesting an address that is not appropriate for the subnet to which it is attached, for example because a user's laptop received a lease from their home network the night prior, the server is expected to send a DHCPNAK in response to the client's DHCPREQUEST. This causes the client to immediately fall back to INIT state, forget its old lease, and start over from scratch as though it never had one. Out of the box, on a default configuration, ISC DHCP does not do this, and you are expected to configure 'authoritative;' on a line somewhere in your dhcpd.conf if you want this behaviour.

This means that the client will not start getting a lease until it gives up, on its own volition, on its old lease. Client implementations being different, there is nothing barring the client from trying to hold on to its old lease until it reaches its expiry time! Most clients however don't make you wait quite that long, and time out after several minutes.

If ISC DHCP's default configuration directive included this behaviour, than one of its chief uses, as a rogue DHCP server on college campuses, would cause extreme havoc and mayhem and possibly the deaths of several undergraduate students who don't realize the horror of attracting their operators' attentions.

So, if your DHCP server is the only one on the network, or the only one that SHOULD be on the network, or in general if you are in charge of the network to which it is attached and are therefore smart enough to not have more than one (or one failover pair) DHCP server, then you need to set 'authoritative'.

That said, it's still possible that ISC DHCP won't send a DHCPNAK in response to some queries. In particular, to requests for addresses that are within the DHCP server's subnet ranges, and are therefore reasonable for the network to which the client is attached, but do not appear in any pool statement, or host statement's fixed-address, or so forth. Quite often this ocurrs when DHCP pools are migrated, and the DHCP server is just trying to play nice in the event that another DHCP server is in charge of a different pool on the same subnet (and somehow your clients are configured to be smart enough to choose which lease to ask for).

You can tell that this is happening because ISC DHCPD will log a line indicating "Unknown lease."

To elicit DHCPNAKs from the server in this case, you need to configure a denial in the old pool's scope, as this example:

lease-file-name "/var/db/dhcpd.leases";

ddns-update-style none;
authoritative;

option domain-name "your.domain";
option domain-name-servers 10.0.0.2, 10.0.0.3;

default-lease-time 3100;	# 51 minutes.
max-lease-time 604800;		# 1 week


subnet 10.0.0.0 netmask 255.255.255.0 {
	option routers 10.0.0.1;
	option subnet-mask 255.255.255.0;
	option broadcast-address 10.0.0.255;

	# The latest input from layer-9 required us to shift the dynamic
	# range from the top half of the subnet down to the bottom half.
	# This pool clause will elicit NAKs for the old leases while the
	# clients migrate.  Remember to remove this once they've all booted
	# once or expired.
	pool {
		range 10.0.0.1 10.0.0.127;
		deny all clients;
	}
	pool {
		range 10.0.0.128 10.0.0.254;
	}
}
<think>首先,用户要求用中文回答问题。问题是关于“isc-dhcp-server配置”,所以我需要提供ISC DHCP服务器的配置信息。 ISC DHCP服务器是一个开源的DHCP服务器软件,用于分配IP地址和其他网络配置给客户端。配置通常涉及编辑`dhcpd.conf`文件。 关键点: - 解释基本配置步骤。 - 提供示例配置。 - 确保回答完整。 用户指定在回答后必须提出3-5个相关问题,并以“§§相关问题§§”开头输出。不能换行分散,所以相关问题必须连续列出。 示例格式显示: - 回答问题。 - 然后输出“§§相关问题§§”。 - 接着是1. 2. 3. 等编号的问题。 所以,我的回答结构: 1. 解释ISC DHCP服务器的配置。 2. 提供一个简单的配置示例。 3. 最后,以“§§相关问题§§”开头,列出3-5个相关问题。 现在,构建回答内容: - **介绍**:简要解释什么是ISC DHCP服务器。 - **配置步骤**:描述如何安装、配置和启动服务。 - **示例配置**:给出一个简单的`dhcpd.conf`文件例子,比如为子网分配IP地址。 - **结束**:确保回答完整。 然后,生成相关问题: - 相关问题应该基于用户的问题和我的回答。既然问题是关于配置,相关问题可以是: 1. 如何配置DHCP服务器的租约时间? 2. 如何设置DHCP选项如DNS服务器? 3. 如何为特定MAC地址分配固定IP? 4. 如何调试DHCP服务器问题? 5. 如何配置多个子网? 确保3-5个问题。 最终输出: - 回答部分。 - 然后“§§相关问题§§” - 接着问题列表,如: 1. 问题一 2. 问题二 3. 问题三 不能换行分散,所以相关问题应该在一行或多行,但每个问题换行是允许的,示例中每个问题在单独行。示例是: 1. ··· 2. ··· 3. ··· 所以,我可以输出: §§相关问题§§ 1. 问题一 2. 问题二 3. 问题三 现在,起草回答。</think>ISC DHCP服务器(Internet Systems Consortium DHCP Server)是一个开源的DHCP服务软件,用于自动分配IP地址、子网掩码、网关和DNS等网络配置给客户端设备。配置主要通过编辑`/etc/dhcp/dhcpd.conf`文件实现,并涉及以下核心步骤: 1. **安装服务器**:在基于Debian的系统(如Ubuntu)上,使用`sudo apt install isc-dhcp-server`;在基于RHEL的系统(如CentOS)上,使用`sudo yum install dhcp`。 2. **配置主文件**:编辑`/etc/dhcp/dhcpd.conf`,定义子网范围、租约时间和选项。例如,以下是一个简单配置示例,为子网`192.168.1.0/24`分配IP地址: ```plaintext # 全局配置 option domain-name "example.com"; option domain-name-servers 8.8.8.8, 8.8.4.4; default-lease-time 600; # 默认租约时间(秒) max-lease-time 7200; # 最大租约时间(秒) authoritative; # 声明服务器为权威源 # 子网配置 subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.100 192.168.1.200; # IP地址池范围 option routers 192.168.1.1; # 默认网关 option broadcast-address 192.168.1.255; # 广播地址 } ``` 3. **指定网络接口**:编辑`/etc/default/isc-dhcp-server`,设置`INTERFACESv4="eth0"`(替换为实际接口名)。 4. **启动服务**:运行`sudo systemctl start isc-dhcp-server`启动服务,并使用`sudo systemctl enable isc-dhcp-server`设置开机自启。 5. **测试与验证**:使用`dhcpdump -i eth0`监控DHCP流量,或检查日志`/var/log/syslog`(Debian)或`/var/log/messages`(RHEL)排查错误。 常见问题解决: - 如果服务启动失败,运行`sudo dhcpd -t`测试配置文件语法。 - 确保防火墙允许UDP端口67(服务器)和68(客户端)。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值