如何在 OpenSUSE 上查看 DHCP 服务器提供的 DHCP 租用时间

如何在 OpenSUSE 上查看 DHCP 服务器提供的 DHCP 租用时间

我需要检查 OpenSUSE Leap 42.2 上的 DHCP 租用时间,我尝试了这些,但它们不起作用:

~> less /etc/dhclient.conf
~> sudo less /var/lib/dhcp/dhclient.leases
# ls -a /var/lib/NetworkManager/
~> sudo ifconfig -a

我怎样才能做到这一点?


我按照@MariusMatutiae 的建议运行以下命令:

linux-box:/var/log # grep -nriIl dhc

YaST2/mkinitrd.log
YaST2/macro_inst_initial.ycp
YaST2/y2log
zypp/history
audit/audit.log
pk_backend_zypp-1
pk_backend_zypp
zypper.log
boot.log

然后我对每个输出文件执行以下操作,但我找不到租期由 DHCP 提供。

linux-box:/var/log # grep -E "dhc" YaST2/y2log

答案1

租用时间存储在其中之一/var/日志文件,但哪个取决于发行版。以下命令

 cd /var/log && grep -nriIl dhclient 

查找所有提到的文件dhclient,就我而言(Debian),很明显该文件是系统日志:

# grep -nirIl dhclient
installer/syslog
syslog
syslog.1
kern.log.1
audit/audit.log.4
audit/audit.log.2
audit/audit.log.1
audit/audit.log.3

然后我得到:

# grep dhclient syslog
Jul  4 08:30:23 hague dhclient[1357]: DHCPREQUEST of 192.168.73.66 on eth0 to 192.168.73.1 port 67 (xid=0x7251b5d5)
Jul  4 08:30:23 hague dhclient[1357]: DHCPACK of 192.168.73.66 from 192.168.73.1
Jul  4 08:30:23 hague dhclient[1357]: bound to 192.168.73.66 -- renewal in 18682 seconds.
Jul  4 13:41:45 hague dhclient[1357]: DHCPREQUEST of 192.168.73.66 on eth0 to 192.168.73.1 port 67 (xid=0x7251b5d5)
Jul  4 13:41:45 hague dhclient[1357]: DHCPACK of 192.168.73.66 from 192.168.73.1
Jul  4 13:41:45 hague dhclient[1357]: bound to 192.168.73.66 -- renewal in 14622 seconds.

这给出了您正在寻找的答案。

答案2

尝试:

less /var/lib/dhcp/db/dhcpd.leases

相关内容