Thursday, April 10, 2014

Debug DHCP troubles, see exactly what the DHCP server is sending me

Scenario: Trouble with DHCP on a client machine. User claims that the DHCP server is not sending the right information. Need to see exactly what DHCP server is sending.

System: openSUSE 13.1


The first thing to realize is that there are two DHCP clients shipped with openSUSE: dhcpcd (the "DHCP Client Daemon") and the ISC DHCP client (package name dhcp-client and binary name /sbin/dhclient).

dhcpcd


The most basic test with dhcpcd is to run the dhcpcd-test bash script as root:
# dhcpcd-test enp0s25
info, enp0s25: hardware address = ...
... etc. lots of output ...

For details take a peek into the script.

dhclient


  1. On a client machine somewhere in the network segment, open the file /etc/sysconfig/network/dhcp and change the DHCLIENT_DEBUG value to "yes"
  2. Read the comment:
    ## Type:        yesno
    ## Default:     no
    #
    # Start in debug mode? (yes|no)
    # (debug info will be logged to /var/log/messages for dhcpcd, or to
    # /var/log/dhclient-script for ISC dhclient)
    #
    DHCLIENT_DEBUG="yes"
    
  3. run dhclient as root
    • if I want to debug a particular interface, add -d $IFACE
    • if I want to dump the entire lease to STDOUT, do dhclient -4 -d -v -sf /bin/true -lf /dev/stdout $ifname
    • if I want to debug a particular DHCP server, add -s $SERVER_IP_ADDR


  4. Study the dumped data in /var/log/dhclient-script
  5. HINT: try deleting the DHCP lease file(s) on the client

No comments:

Post a Comment