Windows: Location of DNS zone files

If the file is not in the %systemroot%\system32\dns directory, the full path to the zone file will be shown on the General tab.

Since most zone data is held in the registry, restoring the %systemroot%\system32\dns from backup isn’t enough – you’ll need to manually populate the DNS zones in the DNS console, and choose the ‘specify location’ option for the zone file on each domain to get the records back.

Windows 2008: Disable password complexity requirement

Method 1

In Windows Server 2008, there is an option in Local Security Policy. Click on Start and then Administrative Tools and then click on Local Security Policy. In Local Security Policy, click on Account Policies and then click on Password Policy. Under Password Policy, double click on “Password must meet complexity requirements” and then select the Disabled option. Then click on Apply and then click on OK. Then close the Local Security Policy and then close the Administrative Tools window.

Method 2

You can use the Group Policy Editor to disable password complexity. Click on Start and then click on Run. In the Run dialog box, type gpedit.msc and hit Enter or click on OK. Then click on Computer Configuration and then Windows Settings and then Security Settings and then Account Policies and then click on Password Policy. Under Password Policy, double click on “Password must meet complexity requirements” and then select the Disabled option. Then click on Apply and then click on OK. Then close the Local Group Policy Editor.

Copy one disk to another using Linux and DD

The following will copy two disks, partition table and all, with forensic quality, and pad the destination disk with zeroes if any data is unreadable on the source disk. Be sure you’ve identified which disk is which using combinations of dmesg and ‘fdisk -l’. The destination disk must also be equal or greater in size.

sudo dd bs=512 if=/dev/sda of=/dev/sdb conv=noerror,sync

bs=512   = Block size 512 bytes
if=/dev/sda   = Source disk /dev/sda (found in dmesg and verified with fdisk -l)
of=/dev/sdb   = Target disk /dev/sdb (found in dmesg and verified with fdisk -l)
conv=noerror,sync   = Ignore errors, pad missing data with zeroes

Grab some coffee or take a drive, as the source disk and overall copy process can be VERY slow if it has medium errors.

Be careful, you will INSTANTLY and completely wipe out the destination disk, partitions and all, so build your command line carefully.

Windows: Ignore errors with Xcopy and RoboCopy

To copy entire directory structures as quickly as possible and ignore all disk errors (useful in data recovery) either of the following commands should work with robocopy being the quickest (if you’ve got Vista/7 or XP with the XP Resource Kit installed). Both commands use source -> destination path order.

xcopy /C/H/R/S/Y c:\ d:\

/C = Continues copying even if errors occur
/H = Copies hidden and system files also
/R = Overwrites read-only files
/S = Copies directories and subdirectories
/Y = Overwrites existing files without asking
robocopy c:\ d:\ /MIR /R:0 /W:0

/MIR = Mirror entire directory structure (can use /E instead)
/R:0 = 0 retries for read/write failures
/W:0 = 0 seconds between retries

Linux: Shutdown/Poweroff command

The other day I was surprised to find the ‘shutdown -h now’ command on the Redhat/Centos rescue CD doesn’t work. I’ve since discovered a few other ways to get a Linux OS to power off, each should accomplish the same thing – gracefully power down.

  shutdown -h now
  halt
  poweroff
  init 0

Cpanel: Install mod_geoip for PHP

First, install the Maxmind GeoIP database.

mkdir /usr/local/share/GeoIP
cd /usr/local/share/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gzip -d GeoLiteCity.dat.gz
wget http://twiki.cpanel.net/twiki/pub/EasyApache3/CustomMods/custom_opt_mod-mod_geoip.tar.gz
tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-mod_geoip.tar.gz

Then, recompile Apache and PHP.

/scripts/easyapache

Cpanel: Clear out catch-all and default email

Cpanel creates a default address inbox for each domain consisting of the Cpanel user’s primary username. This address is not used for normal email, rather as a catch-all (if enabled) or a sink-hole for delivery failures or auto-generated mail from scripts. It is fairly safe to regularly empty out these mailboxes, and it will free up significant space for some domains:

find /home/*/mail/new/ -type f -print0 | xargs -0 rm 

Linux: Sort disk usage with awk

Sort the output of ‘du’ in human readable format (similar to the -h switch).

du -k | sort -nr | awk '
     BEGIN {
        split("KB,MB,GB,TB", Units, ",");
     }
     {
        u = 1;
        while ($1 >= 1024) {
           $1 = $1 / 1024;
           u += 1
        }
        $1 = sprintf("%.1f %s", $1, Units[u]);
        print $0;
     }
    ' > du_sorted.txt

Asterisk: Call rejected, CallToken Support required.

When connected with peers running older versions of Asterisk, the following error might come up and inbound calls from the peer are rejected:

ERROR[xxxxx] chan_iax2.c: Call rejected, CallToken Support required. If unexpected, resolve by placing address x.x.x.x in the calltokenoptional list or setting user guest requirecalltoken=no

To resolve this, place the following in iax_custom.conf and reload Asterisk:

calltokenoptional=0.0.0.0/0.0.0.0;

Cpanel: Undefined subroutine &Compress::Zlib::gzopen

On a particular Cpanel box I occasionally receive the following when attempting to install or update any Perl module — whether initiated by myself or by Cpanel:

Undefined subroutine &Compress::Zlib::gzopen

The fix is to remove all traces of Compress:Zlib with the following command:

rm -rf `find /usr/lib/perl5/ | grep Compress | grep Zlib`

When this happens, it’s likely the Perl modules have become out of sync, so after running the previous command be sure to update everything:

/scripts/checkperlmodules --full