A hacky (but effective) way to debug dhclient on many Linux platforms is to enable bash tracing in /sbin/dhclient-script.
dhclient runs that script on most OS variants I've checked (RedHat, Debian, etc).
Simply adding -x
to the shebang (first line) in that script should enable tracing each line to console, eg:
#!/bin/bash -x
Then you can run, for example
dhclient -r #release lease
dhclient #re-acquire lease
And you should see lots of output, not only from dhclient-script, but from all the included .d
scripts in /etc/dhcp*.
The trace output should allow you to figure out what's happening and what decisions the code is making (reference the script itself when looking at the output).
You can usually deduce the inputs (eg parameters including IP, GATEWAY, etc) the script received from this output, but if not, you can temporarily add something like this to the script just before the exit:
env | logger -t dhclient-debugging
Then check your log after running dhclient (/var/log/messages or /var/log/syslog)
1You'll need to be more specific than "the dhcp client on Linux". There are plenty of different dhcp clients for Linux and they all log different ways. There's probably a default one for Debian 8.1 though I can't remember what it is. – qasdfdsaq – 2015-07-24T10:58:00.837
Internet Systems Consortium DHCP Client 4.3.1 Copyright 2004-2014 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/
– Gustave – 2015-07-24T12:43:54.457