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.

Keeping Up with Cyber Security News

Every day there seems to be some new cyber security issue. Finding information on new issues can be a task in itself.

Here is a list of sites to find information on new threats.

https://www.us-cert.gov/
“US-CERT strives for a safer, stronger Internet for all Americans by responding to major incidents, analyzing threats, and exchanging critical cybersecurity information with trusted partners around the world.”
http://www.forge.mil/
“Forge.mil is a family of services provided to support the DoD’s technology development community. The system enables the collaborative development and use of open source and DoD community source software. For programs and projects that require greater access control, the system supports private collaborative development. Both SoftwareForge and ProjectForge options are fee-for-service. These initial software development capabilities are growing to support the full system life-cycle and enable continuous collaboration among all stakeholders including Project Managers, developers, testers, certifiers, operators, and users.”
https://www.theregister.co.uk/
This UK magazine is one of my principle sources of tech news. It offers relevant stories from the US and around the world.
https://redmondmag.com/
Redmond Magazine offers general computer information on Windows/Server, Active Directory, Exchange Server,  Cloud/Virtual Hosting, SharePoint, Security.

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.

List of Internet top-level domains

I spend a good amount of time looking at domain names and where they are from. Seems a lot of spammers like to use non-standard domain extensions these days. I think that most of it is because not everyone knows about what some call “Brand top-level domains“.

These Brand top-level domain cover just about every club, group, interest, or service that you can think of. From .android to .youtube.

My biggest issue with these are from span. Now spammers have the opportunity to not only user fake a legitimate domain name with .cc but now with .ooo

So, I started adding new regular expressions to my email server filters. For instance, do I need to receive email from .porn or .republican or .democrat ( I did not want you to think that side with politicians ).

This example is used to block email address that have a Return-Path, From address, or Message-ID with a domain with one of following extension.


/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(adult)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(bank|bingo|blackfriday|boo)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(capital|cash|casino|ceo|christmas|cleaning|clothing|church|click|coop|cruises)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(dad|date|degree|democrat|diet|diamonds|directory|download|democrat|dog)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(eat|esq|exchange|exposed)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(fail|faith|family|fashion|foo|fund|furniture|futbol)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(gives|glass|gold|gop|gripe|guru)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(here|hiphop|hiv|holdings|holiday)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(ing|ink|international|investments)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(jewelry)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(kim|kitchen)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(limited|limo|link|loan|loans|lol|lotto|love|luxe|luxury)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(management|mba|meme|men|menu|moe|money)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(new|ninja)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(one|onl|online|ooo)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(party|pharmacy|physio|pizza|plus|poker|porn|post|press|prof)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(racing|red|rehab|ren|rent|rick|rip|rocks|rodeo|rsvp|run)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(sale|sex|sexy|singles|site|social|software|solutions|soy|space|style|sucks|supplies|supply|surf|surgery)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(tattoo|tax|taxi|tel|top)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(uno)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(villas|vision|vodka|vote|voting)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(wang|watch|webcam|website|wed|wedding|whoswho|win|work|works|world|wtf)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(xxx|xyz)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(yoga)>/i
/(Return-Path|From|Message-ID):\s*(.*)\s*<(.*)@(.*)\.(zone)>/i

Some of you might have noticed that I have blocked .love

Is it time to rotate the tires on your computer?

Over the last 20 plus years I have learned a few things about computers. One of them is that you need to “rotate the tires”. By this I mean general servicing of a computer. Most of this is not that hard and really is never talked about. It is like some dark secret that “they” never want you to never know.

So here are a few things you can do to make your computer run slightly better. And can be done overnight while you sleep.

Defrag the hard drive.

Defragmentation of files on your computer can improve your performance. What happens with computer use is that multiple files are always be written to the hard drive at the same time. And the system just uses the first available slot that it can find to store part of a file in. Then jumps to the next free space and so on and so forth until the file is completely written to the hard drive. In some extreme cases a 10MB file might have the first 3 megabytes on the first 25% of drive. Then the rest of file might be dispersed over the rest of the drive.

It is like when you read a newspaper or magazine and they tell you that the story is continued elsewhere. That is kind of annoying. To read something, store it in memory, then jump to page 34 to read more of it. Then find out that you now that to jump to page 40 to finish. But, what if you could defrag the story into one set of pages and be able to read it straight through? Would that not save time from having to flip pages and locate where the story continues from?

Well that is what programs would like to have done. Have all the files needed in the same general area without having get them from all over the hard drive and not have to piece them back together.

Here are few defragging programs that I use periodically to speed up my program loading and file access. You can download more than one. I mainly run two of them. One, Defragger allow you to not only defrag the whole hard drive. But, also just a single file if needed. This is handy on large file like VM images and ISO files that are a few gigabytes in size. The Second, defrag program is Smart Defrag. This one does a cool thing. It will reorder programs based on the usage. This helps if you are using the same program(s) all the time.

There are tons of other defrag programs on the market. Each does things a little different. You will need to read up on them to see if one is better for you. You can do that at CNET.

Uninstall programs

Somewhere on your computer there is at least one program that is installed that you have not used in months. Do you still need it? How much space is it using?

Some games can use a few hundred megabytes. Maybe you should get rid of it. Not just to save hard drive space. But, to increase performance.

How is that done you ask. Well, by removing an application from the system you delete references to is in the system registry and on the hard drive. Then the computer does not have to remember where it was stored or the settings that were stored in registry. And, in some cases that application or part of the application is running in background even if you never run it.

Use the Control Panel to select Programs and Features. You should then see a list of all the programs that can be uninstalled. Select the one you want and click uninstall.

Please note three things. One, some programs require other programs to run correctly. iTunes has several helper programs. Apple Application Support, Software Update, Bonjour, and QuickTime. Be careful which ones you decide to remove. The second thing is that it might be best to shut down your computer for a minute or two after uninstall some programs like trial version of Microsoft Office. This helped in the old days by forcing items in memory to be released and shut down services that might be running still on a restart. The third thing you might want to do is defrag the hard drive after removal and clean the system registry.

Clean the registry

The registry is used to keep track of where and what applications do. I can store default settings for an application and remember on what monitor you last used an application.

Over time the system registry can grow from a few hundred megabytes to several gigabytes. The larger the file the longer the read time. Thus slowing the system down.

So, from time to time you need back up and defrag the registry. Removing old pointers and setting for applications that are no longer on your system.

Two of the products that I used to do this is Wise Cleaner and SpyBot Search & Destroy. WiseCleaner will also defrag the registration file.

It is important to note that in some cases touching the registry might be a bad thing. In some cases it can lead to strange behavior issues with the operating system. I always back up the registry file before performing any changes to it. And playing with it should only be done at your own risk!

Android apps to help me maintain sites when out of the office

Over the years I have noticed that everything breaks when I am away from my workstation.

To avoid have to drive back to the office, my home, or the hotel I have been looking for a good set of Android applications that will allow me access to my code and publish it back to the server or a SVN repository.

The keyboard – A.I. Keyboard Free

The first thing I needed was a full keyboard. Let’s face it you cannot edit long blocks of code or URLs with default touch screen keyboard. So, I downloaded A.I. Keyboard Free.

This keyboard allows for the most important thing needed to navigate source code. Arrow Keys. I know that does not sound like much. But, I have issues with touch devices to going to the spot that I clicked in the URL or in a paragraph.

The keyboard also offers keys to undo and redo text or cut and paste items, use extended symbols, and allow the user to adjust the keyboard size to that which best fits your typing.

SVN – OASVN Free

I will admit there are not a lot of choices for SVN on Android. But, OASVN does a good job for when you are out of the office.

To down load your repository you just need to fill out a few form fields. Set the path where you want to store everything on your mobile device. Then you are ready to check out.

The editor – DroidEdit Free

I needed an application that would do more than a simple text edit. DroidEdit does syntax highlighting, undo, and redo. As an added bonus you open file from the local path, Dropbox, and Box.

When opening a document you can have the application prompt you to select the encoding. This is helpful when working with document such as XML that require UTF-8 encoding.

SSH – ConnectBot

I use a Linux server to host and test my sites. So, I need to be able to SSH to my servers and update the local SVN repository. ConnectBot allows me to that.

Browsers – Firefox,Google Chrome,Dolphin,Opera, etc.

There are several browsers these days for Android. Each behaves and renders things a little differently. So, you will need to find the one that best fits you testing and development needs.

For my sites I like to use Dolphin. It seems to render more like a desktop browser. It allows you to toggle the User Agent between Android, Desktop, iPhone, iPad, and Custom triggering sites to load different versions or a web page. Not all sites will load correctly in Dolphin. This is because of developers limiting what browsers are support on their sites. Just another reason to test things in various browsers and on different devices/platforms.