如何找到我的DHCP服务器?


12

在我的LAN上,有多个正在运行的DHCP服务器,并且它们都在同一范围内。

现在,我使用一台具有来自DHCP服务器的动态IP地址的机器。我必须知道它来自哪台服务器。

怎么做?!

Answers:


11

要找出为您提供IP的DHCP服务器,只需按键盘上的Ctrl+ Alt+ T打开终端。打开时,运行以下命令:

cat /var/lib/dhcp3/dhclient.leases

或者,您可以只使用grep命令来获取DHCP服务器地址。

grep dhcp-server-identifier /var/lib/dhcp3/dhclient.leases

要么

grep dhcp-server-identifier /var/lib/dhcp/dhclient.leases

对于Ubuntu 14.04、16.04和17.10,可以使用:

dhclient -d -nw eth0

样本输出:

Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/00:0c:29:49:3e:67
Sending on   LPF/eth0/00:0c:29:49:3e:67
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x4f723f9)
DHCPREQUEST of 192.168.138.136 on eth0 to 255.255.255.255 port 67 (xid=0x4f723f9)
DHCPOFFER of 192.168.138.136 from 192.168.138.254
DHCPACK of 192.168.138.136 from 192.168.138.254
RTNETLINK answers: File exists
bound to 192.168.138.136 -- renewal in 892 seconds.

还有14.04!
有机大理石

@ScottStensland添加了有关更高版本的Ubuntu的信息。谢谢
米奇

@OrganicMarble添加了有关Ubuntu更高版本的信息。谢谢
米奇

在我的情况下,正在运行的dhclient(即dhclient -d -nw eth0)与已经在运行的dhclient进程混淆了,从而产生了新的IP地址。
Ulrich Stern

12

在Ubuntu 14.04中,/var/lib/dhcp/dhclient.leases为空。实际的租赁文件可以在dhclientvia 的命令行中找到ps。寻找-lf选项。此命令应在Ubuntu 14.04安装中有效(自17.10起仍然有效)

cat $(ps aux | grep -o '[/]var/lib/NetworkManager/\S*.lease') | grep dhcp-server-identifier

在18.04 dhclient.leases中不为空。
Pablo Bianchi


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.