I have a dhcp packets sniffer, which needs to log if it sees dhcp decline response coming from client.I need to know the scenario where client can send dhcp decline response to dhcp server.
I tried to get this reproduce by minimizing small range of ip's at dhcpserver and allocating duplicate static ip's to a client says client_A and running dhclient on client_B.But client_B accepts duplicate ip (ip which is already with ip client_A), instead of sending dhcpdecline response.
Is this a better and guaranteed way to reproduce dhcp decline scenario.
Clients I m using are ubuntu and for dhcp server various options are available like vyos/microsoft.
Thanks and advance !!
Best Answer
It looks like it should be possible, but it's going to require a bit of fiddling...
As you suggested in the comments, dhclient doesn't validate DHCP server responses for router addresses so I went to the documents and found out what kind of situation might cause dhclient to send a DHCPDECLINE.
Dhclient docs show that dhclient-script is called when a lease is issued:
http://manpages.ubuntu.com/manpages/wily/en/man8/dhclient.8.html
Dhclient-script docs show that before configuring the address offered by the DHCP server, dhclient-script ARPs for it and raises a DHCPDECLINE if the address already exists.
http://manpages.ubuntu.com/manpages/wily/en/man8/dhclient-script.8.html
I haven't got a copy of Ubuntu to look at at the mo (check your /etc/dhclient-script), but the source code for the Linux dhclient-script can be found here http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/wily/isc-dhcp/wily/view/head:/client/scripts/linux
I'm thinking (but unfortunately can't test it) that you could backup your existing dhclient-script and edit this section
I think changing
exit $exit_status
toexit 1
would cause any DHCP lease to be declined...Give it a try. If it works as I think it should, it will totally break the DHCP client but should generate a DHCPDECLINE each time you run dhclient.