-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
Unknown lease options don't appear to be dumped by dhcpcd. Microsoft Azure, for example, uses dhcp option 245 to announce its wireserver IP address to cloud instances. The ability to use dhcpcd --dumplease would be very helpful for use cases like this.
$ dhcpcd --dumplease < /var/lib/dhcpcd/eth0.lease
broadcast_address='10.0.0.255'
classless_static_routes='0.0.0.0/0 10.0.0.1 168.63.129.16/32 10.0.0.1 169.254.169.254/32 10.0.0.1'
dhcp_lease_time='4294967295'
dhcp_message_type='5'
dhcp_rebinding_time='4294967295'
dhcp_renewal_time='4294967295'
dhcp_server_identifier='168.63.129.16'
domain_name='ilo2tr0xng2exgucxg20yx0tjb.gx.internal.cloudapp.net'
domain_name_servers='168.63.129.16'
ip_address='10.0.0.5'
network_number='10.0.0.0'
routers='10.0.0.1'
server_name='DSM111070915004'
subnet_cidr='24'
subnet_mask='255.255.255.0'But I wrote some Python which demonstrates that this option is included in the lease:
#!/usr/bin/env python3
import sys
import os
def iter_options(data: bytes, index: int):
"""options are variable length, and consist of the following format
option number: 1 byte
option length: 1 byte
option data: variable length (see length field)
"""
while len(data) >= index + 2:
code = data[index]
length = data[1 + index]
option = data[2 + index : 2 + index + length]
yield code, option
index = 2 + length + index
lease_file = sys.argv[1]
print(f"parsing lease: {lease_file}")
with open(lease_file, "rb") as f:
for code, option in iter_options(f.read(), 240):
print(f" found option {code}: {option}")Which shows that option 245 is in the lease:
$ ./get_options.py /var/lib/dhcpcd/eth0.lease
parsing lease: /var/lib/dhcpcd/eth0.lease
found option 1: b'\xff\xff\xff\x00'
found option 3: b'\n\x00\x00\x01'
found option 6: b'\xa8?\x81\x10'
found option 15: b'ilo2tr0xng2exgucxg20yx0tjb.gx.internal.cloudapp.net'
found option 51: b'\xff\xff\xff\xff'
found option 53: b'\x05'
found option 54: b'\xa8?\x81\x10'
found option 58: b'\xff\xff\xff\xff'
found option 59: b'\xff\xff\xff\xff'
found option 245: b'\xa8?\x81\x10'
found option 121: b'\x00\n\x00\x00\x01 \xa8?\x81\x10\n\x00\x00\x01 \xa9\xfe\xa9\xfe\n\x00\x00\x01'The isc-dhclient lease format shows the options as option unknown-245 a8:3f:81:10;:
lease {
interface "eth0";
fixed-address 10.0.0.5;
server-name "DSM111070915004";
option subnet-mask 255.255.255.0;
option dhcp-lease-time 4294967295;
option routers 10.0.0.1;
option dhcp-message-type 5;
option dhcp-server-identifier 168.63.129.16;
option domain-name-servers 168.63.129.16;
option dhcp-renewal-time 4294967295;
option rfc3442-classless-static-routes 0,10,0,0,1,32,168,63,129,16,10,0,0,1,32,169,254,169,254,10,0,0,1;
option unknown-245 a8:3f:81:10;
option dhcp-rebinding-time 4294967295;
option domain-name "ilo2tr0xng2exgucxg20yx0tjb.gx.internal.cloudapp.net";
renew 0 2160/02/17 02:22:33;
rebind 0 2160/02/17 02:22:33;
expire 0 2160/02/17 02:22:33;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels