网络 - 如何调试DHCP?

分享于 

4分钟阅读

ubuntu

  繁體


首先,运行tcpdump或wireshark,以便在包级别监视,在此示例中,DHCP服务器提供的内部NIC为enp2s0,位于192.168.111.1


doug@DOUG-64:~$ sudo tcpdump -n -tttt -i enp2s0 port 67 and port 68


tcpdump: verbose output suppressed, use -v or -vv for full protocol decode


listening on enp2s0, link-type EN10MB (Ethernet), capture size 262144 bytes


2020-05-18 14:42:30.656940 IP 192.168.111.122.68 > 192.168.111.1.67: BOOTP/DHCP, Request from 04:d4:c4:93:f4:55, length 265


2020-05-18 14:43:07.473233 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 04:d4:c4:93:f4:55, length 287


2020-05-18 14:43:07.473493 IP 192.168.111.1.67 > 192.168.111.122.68: BOOTP/DHCP, Reply, length 300


2020-05-18 14:43:07.473766 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 04:d4:c4:93:f4:55, length 299


2020-05-18 14:43:07.475214 IP 192.168.111.1.67 > 192.168.111.122.68: BOOTP/DHCP, Reply, length 300



重新引导计算机,在192.168.111.122,以便创建一些DHCP流量,包级别的内容查看O.K,如果不O.K,至少我们知道请求包是否到达。

现在,检查这个事务的日志:


doug@DOUG-64:~$ grep dhcpd /var/log/syslog | tail -10


May 18 11:34:12 DOUG-64 dhcpd[1141]: DHCPACK on 192.168.111.122 to 04:d4:c4:93:f4:55 via enp2s0


May 18 14:25:29 DOUG-64 dhcpd[1141]: DHCPREQUEST for 192.168.111.110 from a4:ee:57:e6:d0:0b via enp2s0


May 18 14:25:29 DOUG-64 dhcpd[1141]: DHCPACK on 192.168.111.110 to a4:ee:57:e6:d0:0b via enp2s0


May 18 14:28:07 DOUG-64 dhcpd[1141]: DHCPREQUEST for 192.168.111.112 from f4:6d:04:65:2d:8e via enp2s0


May 18 14:28:07 DOUG-64 dhcpd[1141]: DHCPACK on 192.168.111.112 to f4:6d:04:65:2d:8e via enp2s0


May 18 14:42:30 DOUG-64 dhcpd[1141]: DHCPRELEASE of 192.168.111.122 from 04:d4:c4:93:f4:55 via enp2s0 (not found)


May 18 14:43:07 DOUG-64 dhcpd[1141]: DHCPDISCOVER from 04:d4:c4:93:f4:55 via enp2s0


May 18 14:43:07 DOUG-64 dhcpd[1141]: DHCPOFFER on 192.168.111.122 to 04:d4:c4:93:f4:55 via enp2s0


May 18 14:43:07 DOUG-64 dhcpd[1141]: DHCPREQUEST for 192.168.111.122 (192.168.111.1) from 04:d4:c4:93:f4:55 via enp2s0


May 18 14:43:07 DOUG-64 dhcpd[1141]: DHCPACK on 192.168.111.122 to 04:d4:c4:93:f4:55 via enp2s0



传输一切顺利,我们知道DHCP服务器已经获得并处理了流量。这个示例租约是基于MAC的,并且不出现在/var/lib/dhcp/dhcpd.leases中,检查基于池的租约的下一个地方,例如:


lease 192.168.111.46 {


 starts 1 2020/05/18 01:53:46;


 ends 2 2020/05/19 01:53:46;


 cltt 1 2020/05/18 02:21:41;


 binding state active;


 next binding state free;


 rewind binding state free;


 hardware ethernet e4:e4:ab:08:6a:6b;


 uid"0134434425310jk";


}





network  DEB  debug  网络  DHCP  
相关文章