How to read /var/lib/dhcpcd/interface.lease file?

Viewed 82

I am connected to a LAN-Network using dhcpcd. I am trying to view my current lease. A file is created in the directory /var/lib/dhcpcd/ with the name interface.lease which I'm trying to read. I am getting a cryptic output, why?

cat interface.lease gives the output

�;��
)

)��c�Sc56
3Q�:��;'P��
��
domain
   hostname

As you can see the domain and hostname can be seen, but the rest is scrambled.

I have been unable to find answers using google and I'm getting a bit frustrated since it works without problems if I'm using dhclient for example. However the project I'm working on uses dhcpcd, so this is not an option.

1 Answers

You're getting the binary data just as it is sent from the DHCP server - this is how dhcpcd does it - unlike dhclient which writes the ASCII text instead. However, the ASCII text is available from dhcpcd by using the --dumplease interface option for dhcpcd:

$ dhcpcd --dumplease wlan0   # or eth0, or whatever
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'

N.B. This response may not be typical due to the options set in my /etc/dhcpcd.conf.

But in some cases, this is not particularly helpful for troubleshooting. For those cases, I'd suggest installing dhcpdump so that you can see both sides of the client-server conversation, and/or invoking dhcpcd's debug option by adding to the /etc/dhcpcd.conf, or from the command line (see man dhcpcd & man dhcpcd.conf).

Related