Answers:
要找出为您提供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.
dhclient
(即dhclient -d -nw eth0
)与已经在运行的dhclient
进程混淆了,从而产生了新的IP地址。
在Ubuntu 14.04中,/var/lib/dhcp/dhclient.leases
为空。实际的租赁文件可以在dhclient
via 的命令行中找到ps
。寻找-lf
选项。此命令应在Ubuntu 14.04安装中有效(自17.10起仍然有效):
cat $(ps aux | grep -o '[/]var/lib/NetworkManager/\S*.lease') | grep dhcp-server-identifier
dhclient.leases
中不为空。
带有:
sudo nmap --script broadcast-dhcp-discover -e eth0
sudo nmap --script broadcast-dhcp6-discover -6 # DHCPv6
sudo dhcpdump -i eth0
sudo tcpdump -i eth0 -nev udp port 68
其他:
dhcp_probe
(dhcp-probe
包装)