0

I need to check out DHCP lease time on OpenSUSE Leap 42.2, I tried these, but they didn't work:

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

How can I do that?


I run the following command as suggested by @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

Then I do the following for each output file, but I couldn't find the lease time provided by DHCP.

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

2 Answers 2

1

The lease time is stored in one of the /var/log files, but which one depends on distro. The following command

 cd /var/log && grep -nriIl dhclient 

finds all files mentioning dhclient, and in my case (Debian) it is clear that the file is syslog:

# 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

Then I get:

# 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.

which gives the answer you are searching for.

2
  • I did # cd /var/log/ && grep -nriIl dhclien, the output is YaST2/y2log and audit/audit.log. However, # grep dhclient YaST2/y2log returns nothing and # grep dhclient audit/audit.log returns: type=USER_CMD msg=audit(1499168810.664:1514): pid=5925 uid=1000 auid=1000 ses=2 msg='cwd="/home/mydear" cmd="dhclient" terminal=pts/3 res=success'
    – Megidd
    Jul 4, 2017 at 12:34
  • @user3405291 Try using dhc instead of dhclient, you may have dhcpcd running instead of dhclient. Jul 4, 2017 at 12:45
0

Try:

less /var/lib/dhcp/db/dhcpd.leases
1
  • 2
    Welcome to the site, and thank you for your contribution. However, it would appear that the OP is trying to find out the lease time on the client machine, indicating that no access to the server is available/granted. You may want to add a few words of explanation concerning that issue.
    – AdminBee
    Feb 4, 2020 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .