1

OS is Debian 10-12. I know in some (most?) cases, a DHCP server will provide DNS servers at the same time as it leases an ip address.

I would like to use dhclient to get a list of DNS servers provided by the DHCP server.

(I realize I can look in /var/lib/dhcp for a lease file, but I want to do an active query in order to check the current state of the DHCP server.)

4
  • 1
    dhclient works by receiving information from the DHCP server and then calling out to script (by default /sbin/dhclient-script) to make the necessary changes on your system. You can write your own script to replace the default dhclient-script and do whatever you want with that information (dhclient -sf /path/to/my/script). Commented Sep 19, 2023 at 20:23
  • Is there a way to just print the data to stdout without modifying my system? Commented Sep 19, 2023 at 20:42
  • 1
    You don't need to "modify your system". You just need to create a new script file (possibly a temporary file you create as part of a larger shell script). Commented Sep 19, 2023 at 21:02
  • Gotcha, I just want to be sure I don't interfere with the normal operation of dhclient while using a system to test the dhcp server Commented Sep 19, 2023 at 21:21

1 Answer 1

0

Once you select the interface (ip link show/networkctl list/nmcli device status) you can use dhcpcd (sudo apt install dhcpcd5) Test Mode.

sudo dhcpcd --test eth0 | grep new_domain_name_servers 

Also, you can sudo nmap --script broadcast-dhcp-discover -e eth0,or use tcpdump and pipe it to dhcpdump.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.