dnsmasq DHCP服务器无响应问题排查求助
dnsmasq DHCP服务器无响应问题排查求助
各位大佬好,我折腾好几天了还是没解决这个问题,想请大家支支招!
我的环境与配置情况:
- 硬件:树莓派通过两个TP-Link TL-PA4010电力线适配器连接海康摄像头
- 系统:树莓派跑的是标准Raspbian(Debian GNU/Linux 11 (bullseye))
- 树莓派eth0静态IP配置(
/etc/dhcpcd.conf):
interface eth0 static ip_address=192.168.0.10/24
- 用dnsmasq搭建的DHCP服务器,配置文件内容:
# Disable DNS port=0 # Configuring the DHCP server interface=eth0 dhcp-leasefile=/var/lib/misc/dnsmasq.leases # The MAC address of the IP camera dhcp-host=xx:xx:xx:xx:xx:xx,192.168.0.11 # I've added this later, didn't do anything dhcp-authoritative # Some logging log-dhcp log-queries log-facility=/var/log/dnsmasq.log
问题现象:
这个配置之前是能用的,我能正常获取摄像头的图像,但现在摄像头死活连不上树莓派的DHCP服务器——拿不到IP地址。
- 摄像头连我家主网的话,能正常获取IP,也能打开它的网页管理界面
- 我已经把摄像头重置到出厂设置,重新设为DHCP模式,还是没用
- 用
tcpdump抓eth0的流量,能看到摄像头一直在发DHCP请求:
17:46:36.725552 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 284 17:46:39.726180 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 284 17:46:42.727918 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 284
- 但dnsmasq完全没响应,日志里只有启动记录,没有任何DHCP相关的处理日志:
Apr 29 17:33:57 dnsmasq[590]: started, version 2.85 DNS disabled Apr 29 17:33:57 dnsmasq[590]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset auth cryptohash DNSSEC loop-detect inotify dumpfile
已尝试的操作:
- 重置摄像头到出厂设置,重新配置为DHCP模式
- 删除了旧的lease文件
/var/lib/dhcp/dhclient.leases(之前成功连接的记录在里面,看网上说删了试试,但没用) - 确认dnsmasq服务运行正常,systemd状态如下:
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2023-04-29 17:33:57 CEST; 15min ago Process: 538 ExecStartPre=/etc/init.d/dnsmasq checkconfig (code=exited, status=0/SUCCESS) Process: 570 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS) Process: 594 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS) Main PID: 590 (dnsmasq) Tasks: 1 (limit: 779) CPU: 435ms CGroup: /system.slice/dnsmasq.service └─590 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d3> Apr 29 17:33:55 raspberrypi systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server... Apr 29 17:33:57 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
- 确认树莓派没有防火墙,执行
sudo systemctl stop firewall提示服务未加载,说明没装防火墙
我的猜测:
我觉得问题应该出在树莓派这边,因为:
- 能抓到摄像头的流量,说明电力线适配器是正常工作的
- 摄像头能从家里网关的DHCP服务器拿到IP,说明摄像头本身没问题
现在实在没头绪了,想问问大家可能是什么问题?还有哪些可以排查的方向?
备注:内容来源于stack exchange,提问作者Luke Skywalker




