0

How do I manually purge ALL dhcpd.lease ?

Can I just sudo echo /dev/null > /var/lab/dhcpd/dhcpd.lease ?

It's a special use case of testing ground; we have an isolated LAN for developers to do test run. And after each testing session I'd need to reset everything to initial state, including DHCP lease records. The test session would take few days to just few hours, so I can't rely on dhcpd auto-purge.

The DHCP server is running on Rocky Linux 8 (X86-64).

[EDIT]

The command should be cat /dev/null | sudo tee /var/lab/dhcpd/dhcpd.lease. Thanks for the tip.

RichardLiu
  • 143
  • 1
  • 5
  • Does this answer your question? [How do I manually release a DHCP lease on the DHCP server itself?](https://serverfault.com/questions/739022/how-do-i-manually-release-a-dhcp-lease-on-the-dhcp-server-itself) – Romeo Ninov Jun 27 '23 at 06:25
  • 1
    `echo /dev/null` will output the string `/dev/null` ... and `sudo command > file` won't do what you think, the output redirection is still as the current user ... perhaps you wanted `cat /dev/null | sudo tee /var/lab/dhcpd/dhcpd.lease` (after stopping the dhcp server of course) – Jaromanda X Jun 27 '23 at 06:49
  • @JaromandaX yeah I mean `cat /dev/null`. Sorry for typo. Thanks for the `sudo tee` trick. – RichardLiu Jun 27 '23 at 08:44
  • @RomeoNinov It does, but in the hard way. I don't care about the lease record during test run at all and I don't want to *carefully* edit `dhcpd.lease` manually between each test run session. I just want to zap everything. Actually, I'm asking whether there is anything in the `dhcpd.lease` file that I shouldn't delete. – RichardLiu Jun 27 '23 at 08:48

0 Answers0