Is your DHCP Server Authoritative?

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;
	}
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的控制WIFI工作在AP模式,并开启DHCP SERVER的shell脚本: ``` #!/bin/bash # 设置无线网卡名称 WLAN="wlan0" # 停止无线网卡正在运行的服务 sudo service network-manager stop # 配置无线网卡为AP模式 sudo ifconfig $WLAN down sudo iwconfig $WLAN mode master sudo ifconfig $WLAN up # 配置IP地址和子网掩码 sudo ifconfig $WLAN 10.0.0.1 netmask 255.255.255.0 # 启动DHCP服务 sudo apt-get update sudo apt-get install isc-dhcp-server -y # 配置DHCP服务 sudo sed -i 's/INTERFACESv4=""/INTERFACESv4="'$WLAN'"/g' /etc/default/isc-dhcp-server sudo sed -i 's/option domain-name "example.org";/option domain-name "mydomain.local";/g' /etc/dhcp/dhcpd.conf sudo sed -i 's/option domain-name-servers ns1.example.org, ns2.example.org;/option domain-name-servers 8.8.8.8, 8.8.4.4;/g' /etc/dhcp/dhcpd.conf sudo sed -i 's/#authoritative;/authoritative;/g' /etc/dhcp/dhcpd.conf sudo sed -i 's/192.168.1.0/10.0.0.0/g' /etc/dhcp/dhcpd.conf sudo sed -i 's/192.168.1.100/10.0.0.2/g' /etc/dhcp/dhcpd.conf sudo sed -i 's/192.168.1.200/10.0.0.254/g' /etc/dhcp/dhcpd.conf # 启动DHCP服务 sudo service isc-dhcp-server start # 输出配置信息 echo "WIFI is now in AP mode." echo "SSID: LinuxAP" echo "Password: password" echo "IP address: 10.0.0.1" ``` 注意,这个脚本需要使用 `sudo` 执行,因为它需要访问系统的网络配置。还要注意,这个脚本只是一个简单的示例,实际应用中可能需要根据具体情况进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值