Get DHCP Network Settings

From Leo's Notes
Last edited on 14 June 2020, at 22:28.

If you need to determine the specific DHCP configuration that's returned by the DHCP server, use dhclient and pass env as the executed script.

Since dhclient runs scripts with the network settings as part of the environment, this will print the network settings out.

You will need to run this as root.

Example:

# dhclient -sf /usr/bin/env --no-pid -4  -lf /dev/null
pid=8601
reason=PREINIT
interface=virbr0-nic
PATH=/usr/sbin:/sbin:/bin:/usr/sbin:/usr/bin
pid=8601
reason=PREINIT
interface=virbr0
PATH=/usr/sbin:/sbin:/bin:/usr/sbin:/usr/bin
pid=8601
reason=PREINIT
interface=p10p1
PATH=/usr/sbin:/sbin:/bin:/usr/sbin:/usr/bin
requested_routers=1
requested_domain_search=1
requested_interface_mtu=1
requested_ntp_servers=1
requested_nis_servers=1
requested_nis_domain=1
requested_host_name=1
requested_domain_name_servers=1
requested_domain_name=1
requested_classless_static_routes=1
requested_time_offset=1
requested_broadcast_address=1
requested_subnet_mask=1
new_expiry=1496515871
new_domain_name=cs.ucalgary.ca
new_host_name=leo-linux
new_ntp_servers=136.159.5.75 136.159.5.76
new_dhcp_server_identifier=136.159.5.75
new_domain_name_servers=136.159.5.75 136.159.5.76
new_dhcp_message_type=5
new_dhcp_lease_time=86400
new_routers=172.17.10.1
new_subnet_mask=255.255.255.0
new_filename=/pxelinux.0
new_broadcast_address=172.17.10.255
new_network_number=172.17.10.0
new_next_server=172.20.1.10
new_ip_address=172.17.10.9
pid=8601
reason=BOUND
interface=p10p1
PATH=/usr/sbin:/sbin:/bin:/usr/sbin:/usr/bin

What I wanted this for primarily was to verify that the network settings were correct - such as the PXE next-server and the filename that is being given assigned by the DHCP server.