I am on a server, whoose network is set statically:

auto eth0
iface eth0 inet static

How can I, from the commandline, pretend I am DHCP client, and ask DHCP server for network info?

I don't actually want to change the network settings, but I want to see what DHCP info the server would send back.

Specifically, I have nameservers set statically in /etc/resolv.conf and they don't work. I want to see what nameservers the DHCP server would send me, if I set my interface dynamically

I tried dhcping but that does not really work. I don't know the IUP address of the DHCP server on my network. Without any pareameters:

# dhcping
dhcping -c ciaddr -g giaddr -h chaddr -r -s server -t maxwait -i -v -q

I only know the gateway, but specifying gateway does not work:

dhcping  -g
no answer
  • 1
    I use dhcpdoctor which is a python tool that does exactly that. You don't need to specify the gateway or the DHCP server address, it will send a DHCP broadcast, just like a regular DHCP query, and return the exact response - IP, netmask, GW etc. That's the best and easiest tool I've found so far for this purpose.
    – aviro
    Feb 7, 2022 at 8:01

1 Answer 1


For me, dhcping works:

$ sudo dhcping -v -s
Got answer from:

You can use -V to see the packets exchanged. However, as it's not a real request, I got a NACK, and no nameserver information.

It doesn't work without the server address for me, apparently it doesn't do a broadcast?

As for -g, see the man dhcping:

   -g gateway-IP-address
        Use this IP address for the gateway IP address in the DHCP packet.  This option is currently broken.

You could also use dhclient, but that will change your network configuration, so you'll have to manually restore if afterwards. But it's the best way I know of to get actual information.

There is dhcpdump which will show the DHCP packets on the network interface. This will include nameserver information, but needs something to trigger the exchange.

The gateway address often is the same address as the server where DHCP runs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .