1

I am having problems with the dhcp leases of my eth0 interface. My rpi does not renew its lease when it expires.

My lease file has many special characters, is this normal?

enter image description here

My configuration :

  • Compute Module 4 with Debian bullseye 11 5.18.0

Thank you in advance

Seamus
  • 23,558
  • 5
  • 42
  • 83
maxmet
  • 13
  • 3

1 Answers1

2

Your only question was this: "My lease file has many special characters, is this normal?". The answer to that question is, "Yes - it's normal for dhcpcd". Other DHCP clients - dhclient for example - decode the binary data, making it easier to read. AFAICT, the binary data deposited in the lease file by dhcpcd is rendered in human-readable form using dhcpcd --dumplease <intfc> as shown in the example below.

Having answered your question :) I'll take a stab at helping you resolve what I imagine your problem(s) might be:

  • I suspect that reviewing your lease file is not going to be x-helpful, but perhaps I am selling you short? If you feel the path to a solution is in reviewing DHCP lease messages, I'd suggest you take a look at the tool called dhcpdump. It's easy to use, and it gives you visibility of both sides of the DHCP client-server exchange: dhcpcd-to-server, and server-to-dhcpcd.

    I've included an example from running dhcpdump on my system at the bottom of this answer. You can install dhcpdump from the RPi ports tree in the usual way. The man dhcpdump is not hugely helpful, but there are several decent "how-to" guides available; e.g. 1, 2.

  • dhcpcd has a debug mode that you may find useful. You may invoke it from /etc/dhcpcd.conf by adding a line with the word debug. You may also invoke the debug output from the command line as follows:

    $ sudo dhcpcd --debug wlan0
    sending commands to master dhcpcd process
    send OK 
    $ tail -f /var/log/syslog | grep dhcpcd
      # to view the syslog output (or use journalctl)
    
  • You didn't provide anything re. your /etc/dhcpcd.conf file... have you made changes? If so, what are they? Most (> 98%) of the issues with dhcpcd are a result of users making changes to this file which "backfire". So if dhcpdump doesn't enable you to find & resolve your issues, you may edit your question to add some of those details & we'll try to help further.

dhcpcd --dumplease for /var/lib/dhcpcd/<intfc> file:

$ dhcpcd --dumplease wlan0
broadcast_address='192.168.1.255'
dhcp_lease_time='7200'
dhcp_message_type='5'
dhcp_server_identifier='192.168.1.1'
domain_name='seamus.local'
domain_name_servers='192.168.1.1'
ip_address='192.168.1.143'
network_number='192.168.1.0'
routers='192.168.1.1'
subnet_cidr='24'
subnet_mask='255.255.255.0'
dhcp6_client_id='00010001290fe939b827eb987aaa'
dhcp6_domain_search='seamus.local'
dhcp6_ia_na1_ia_addr1='2605:a601:a80a:b900::133d'
dhcp6_ia_na1_ia_addr1_pltime='4500'
dhcp6_ia_na1_ia_addr1_vltime='7200'
dhcp6_ia_na1_iaid='eb987aaa'
dhcp6_ia_na1_t1='0'
dhcp6_ia_na1_t2='0'
dhcp6_name_servers='2605:a601:a80a:b900:225:90ff:fee0:a775'
dhcp6_reconfigure_accept=''
dhcp6_server_id='0001000123e6bf35002590e0a775'

dhcpdump usage:

$ sudo dhcpdump -i wlan0
  TIME: 2022-06-14 21:24:32.585
    IP: 192.168.1.143 (b8:27:eb:68:8c:ca) > 192.168.1.1 (0:25:90:e0:a7:75)
    OP: 1 (BOOTPREQUEST)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: 923bad8b
  SECS: 65535
 FLAGS: 0
CIADDR: 192.168.1.143
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: b8:27:eb:68:8c:ca:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         3 (DHCPREQUEST)
OPTION:  61 (  7) Client-identifier         01:b8:27:eb:68:8c:ca
OPTION:  57 (  2) Maximum DHCP message size 1472
OPTION:  60 ( 45) Vendor class identifier   dhcpcd-8.1.2:Linux-5.15.32-v7+:armv7l:BCM2835
OPTION:  12 ( 13) Host name                 raspberrypi3b
OPTION: 145 (  1) ???                       01               .
OPTION:  55 ( 14) Parameter Request List      1 (Subnet mask)
                        121 (Classless Static Route)
                         33 (Static route)
                          3 (Routers)
                          6 (DNS server)
                         12 (Host name)
                         15 (Domainname)
                         26 (Interface MTU)
                         28 (Broadcast address)
                         51 (IP address leasetime)
                         54 (Server identifier)
                         58 (T1)
                         59 (T2)
                        119 (Domain Search)

TIME: 2022-06-14 21:24:32.588 IP: 192.168.1.1 (0:47:90:d3:a7:75) > 192.168.1.143 (b8:27:eb:68:8c:ca) OP: 2 (BOOTPREPLY) HTYPE: 1 (Ethernet) HLEN: 6 HOPS: 0 XID: 923bad8b SECS: 65535 FLAGS: 0 CIADDR: 192.168.1.143 YIADDR: 192.168.1.143 SIADDR: 0.0.0.0 GIADDR: 0.0.0.0 CHADDR: b8:27:eb:68:8c:ca:00:00:00:00:00:00:00:00:00:00 SNAME: . FNAME: . OPTION: 53 ( 1) DHCP message type 5 (DHCPACK) OPTION: 54 ( 4) Server identifier 192.168.1.1 OPTION: 51 ( 4) IP address leasetime 5949 (1h39m9s) OPTION: 1 ( 4) Subnet mask 255.255.255.0 OPTION: 3 ( 4) Routers 192.168.1.1 OPTION: 6 ( 4) DNS server 192.168.1.1 OPTION: 15 ( 12) Domainname seamus.local


Seamus
  • 23,558
  • 5
  • 42
  • 83