Pi-Hole – Set the Database Max Days

I keep running out space on my Pi-Hole device. To limit this I invoked the MAXDBDAYS argument in the Pi-Hole FTL configuration.

  • Login into your Pi-Hole device via SSH.
  • At the prompt type or paste the following code to stop the FTL service:
sudo service pihole-FTL stop
  • Next type or paste the following line of code to edit the FTL configuration file
sudo nano /etc/pihole/pihole-FTL.conf
  • In the editor scroll down to the last lime of the document

#; Pi-hole FTL config file
#; Comments should start with #; to avoid issues with PHP and bash reading this file
PRIVACYLEVEL=0
RATE_LIMIT=1000/60
  • Add the following line of code. In this example I have set the number of days to 14. You can updated it to be longer or shorter
MAXDBDAYS=14
  • Save the file and exit the editor.
  • Type or paste the following code to start the FTL service:
sudo service pihole-FTL start

Your computer’s “host” file and you.

Your computer’s “host” file is used to map a hostname to an IP address in a local area network (LAN) and/or wide area network (WAN).

Great, so what does that mean? Well say you a created a web server on a Virtual Machine (VM) for testing and you wanted to access the machine by the domain name you assigned it. You could add or update a Domain Name Server (DNS) and point the domain to a public IP address. But, if the web server is in a LAN it may not be accessible and it might take a few hours for you Internet Service Provider’s (ISP) to populate your DNS update.

To save time you could update your computers host file. This plain text file is on Linux and Windows machines that is used first when making calls to domain names. All you need is the IP address of the server and the domain name.

Editing the host File.

For this example we will be using Windows 7. But, most operating systems (OS) use the same general process.

  • Click the Windows Start button.
  • Click the All Programs menu option.
  • Click to open the Accessories menu folder.
  • Right-mouse-click on the Notepad menu option.
  • In the Notepad program window left-click the File
    menu option on the main menu bar.
  • Next click the sub-menu option Open.
  • In the Open dialog box navigate to the folder C:\Windows\System32\drivers\etc\. Initially the folder will appear empty.
  • In the bottom right of the dialog change the select box field from Text Documents (*.txt) to All Files (*.*). This will show you 4 to 5 files.
  • Click and highlight the file hosts
  • In the bottom right of the dialog press Open
  • The contents of an the file start like this:
    # Copyright (c) 1993-2009 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    		
  • Scroll to the bottom of the document.
  • Type in the IP address, press the Tab key on your keyboard, and type the domain name.
  • Save the file change by pressing Ctrl-S on your keyboard.
  • Here I added a record to point to a WordPress test site that I added to my LAN.
    # Copyright (c) 1993-2009 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    
    10.10.10.201	test.lighthouseknowledgedotcom.wordpress.com
    		

It should be noted that most browsers will automatically pickup on the changes to the host file. But, some browsers will need to be restarted to affect the changes.

PowerShell – What happen in the last 72 hours

I have been looking for a way to quickly review log files to look for error within the last 72 hours on servers. I hobbled this PowerShell script together to check the System, Application, and Setup log files and dump the results into a table grid one the screen.

Get-WinEvent -FilterHashTable @{LogName="System","Application","Setup"; StartTime=(get-date).AddHours(-72); EndTime=(get-date).AddHours(0); Level= "1","2"; } | Format-Table TimeCreated,ProviderName,Id,Message -AutoSize

Search files missing a word/string.

I needed to search through a few hundred files and directories to look for all the HTML documents that did not contain the string “jQuery.js“.

I found that the DOS command find with the parameter /c could be used to search for a string and return a “count of lines”. Adding the second parameter /i I could the search and ignore the case of the string in the search.

Borrowing from various sources I created this line of code:

find /c /i "jquery.js" C:\SITES\xyz\wwwroot\*.htm* | find ": 0";

This did provide me with a list of files that did not contain the strings jQuery.js. But, only ran in the C:\SITES\xyz\wwwroot\ and did not reference and of the sub-directories.

Next I needed a way to loop through a folder and it’s sub-directories. I found a line of code that does a for loop reading all of the files and folders an echos their name to the screen via the variable %v.

for /r %v in (*.cf*) do echo %v

After looking at the two lines of code for awhile I figured out a way to combine the line together and save the output to a file.

(for /r %v in (*.cf*) do (find /c /i "jquery.js" "%v" | find ": 0")) > c:\temp\dump.txt

The line of code does need to be run from the folder you wish to search.

VMware and Kernel updates

This week I made my laptop dual boot Windows 7 and Ubuntu 12.11 workstation. This morning I updated the Kernel to 3.5.0-26. After restart I tried running VMWare Player and it failed.

Seems that kernel update did not download update or install the latest lunix-headers that VMWare were missing for the new kernel. I located to command lines to download the the linux-headers.

First I ran the following command to see what version of the kernel I had installed.

uname -r

Next I downloaded the linux-headers for that kernel.

sudo apt-get install linux-headers-3.5.0-26-generic

This downloaded the linix-headers for 3.5.0-26 and 3.5.0-26-generic. The files that I needed were added to the /usr/src/ folder.

I then tried to run VMWare Player again. It asked me here the header files were for the kernel were. The application allowed me to browse to the folder /usr/src/linux-headers-3.5.0-26-generic/ and select it. Then VMWare Player used those linux-header files to compile to the code it needed.

Once completed I was able to start and run VMWare Player.