Sunday, April 17, 2022

pfSense - Delete Expired DHCP Leases Manually

 

 

Intro:

Here's a quick way to remove/purge all expired DHCP leases from pfSense if you don't feel like waiting until pfSense reclaims them.

 This is also super helpful if an IP address is mistakenly assigned to the wrong MAC via DHCP and you then need to assign it as static to a different MAC. If you're making quick changes to the DHCP server you'll find a use for this.

 

Fix:

  1. Log into your pfSense box.
  2. Top right, click on "Diagnostics" ➡ "Edit File".
  3. Load "/var/dhcpd/var/db/dhcpd.leases".
  4. Select the blocks that you need to remove. Each block of data begins with the word "leases" and ends with a curly brace, "}".
  5. When done editing the file directly click on "Save" near the top left of the edit box.

 

Extras:

There may be another file with the same name but with a tilde "~" sign after it. This file indicates that it is a backup of the original "dhcpd.leases" file. To be sure you've changed it in all necessary files, go ahead and delete the leases from this backup file as well or make life easy and just copy the "dhcpd.leases" content over to the "dhcpd.leases~" file and save.
 
DHCPv6 Leases can also be deleted but the file names are slightly different as seen below, however the files reside in the same folder as the IPv4 files:
 

IPv6:

  • dhcpd6.leases
  • dhcpd6.leases~

IPv4:
  • dhcpd.leases
  • dhcpd.leases~


πŸ‘½

Copy Saved PuTTY Sessions from One Computer to Another


Intro:

I needed to move all my saved sessions from my main PC to my laptop. Instead of recreating them one by one I decided to dig around and see where PuTTY saves it's sessions to.

Fortunately they are saved in the Windows Registry and a quick export and import on the new machine is all that's needed.

Fix:
  1. Press the Windows key and search for "regedit.exe" on the source machine.
  2. If you're on Windows 10 you can paste the following link into regedit, "HKEY_CURRENT_USER\Software\SimonTatham\PuTTY".
  3. Right click on the tree named, "PuTTY" and select "Export".
  4. Save the file with a memorable name and to a location that you can use later to recall the saved .reg file.
  5. On the target computer recall that .reg file.
  6. Make sure PuTTY is not open. If it is, close it.
  7. Double click on that .reg file and select "Yes" to merge the file with the current registry.
  8. One that file has been imported open PuTTY and check that everything looks as it should.
  9. IMPORTANT - If you have saved certificates they will point to a location on the previous machine. You should copy them over with the same file name and folder structure as on the source machine.


πŸ‘½

Making Direct Changes to the Windows Host File


Intro:

There has to be a quick and easy way to edit the Windows Hosts file directly.

Also the following directions have been tested in Windows 10 only, however I'm sure they'll work in previous versions that use UAC.

Here's some information on the Wiki about Hosts files in general:


Problem:

Needed to edit the Windows host file without copying it to the Desktop, making changes to it, copying it back to the Windows folder.


Fix:

  1. Press the Windows Key.
  2. Type "notepad" in the search box.
  3. Right click on "Notepad" in the search box and select "Run as Administrator"
  4. In Notepad click on "File" ➡ "Open"
  5. Paste in "c:\windows\system32\drivers\etc\hosts".
  6. Make the necessary changes to the file.
  7. Select "File" ➡ "Save".



πŸ‘½