How to set the fully qualified domain name (FQDN) in Ubuntu 12.04 LTS

To set the fully qualified domain name (FQDN) for a Ubuntu 12.04 LTS host, one needs to edit the /etc/hosts file. Please note that the FQDN is specified in the hosts file and not the /etc/hostname file. In the following example the fully qualified domain name is myhost.example.com, where myhost is the host’s name and example.com is the domain name. Use vi to edit the hosts file:

sudo vi /etc/hosts

Use the insert (i) command to enter edit mode in vi and modify the following value:

127.0.1.1 myhost

Change it to and save the file using Escape and :x vi command:

127.0.1.1 myhost.example.com myhost

Now test your configuration:

hostname

Should return the value:

myhost

And this command:

hostname -f

Should return the value:

myhost.example.com

Please note the process to set the FQDN in the current 13.10 release is the same as in the 12.04 LTS version.

For additional information take a look at the official Ubuntu documentation:

Posted in How To, Management, Operating Systems | Tagged , , , , | Comments Off

How to get better Google ranking and improve SEO by configuring WordPress permalink settings

The following graph shows summary statistics for visitors and page views of this blog over a period of one year (July 2012 — July 2013). As you can see the visitor count was fairly steady throughout the year, with a sudden drop off in April/May 2013, followed by an exponential increase in traffic week-over-week since that point in time.

graph_summary_areachart_2012-07_2013-08

As you may guess from this post’s title — the visitor traffic pattern has changed back in May due to the fact that I adjusted the WordPress permalink settings. A bit of background info about permalinks: “By default WordPress uses web URLs which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links.”

Around the time when I started this blog, I also signed up for Twitter. Back then, I was too lazy to look for a good URL shortner, which was required at the time if you wanted to post links on Twitter. Now of course the URL shortner is built into Twitter and is automatically embedded into every link in order to obtain detailed traffic analytics (which is what Twitter is trying to monetize). In any case, back then I chose a Numeric structure (http://baudlabs.com/archives/123) for my permalinks. I thought it would look cleaner, be less prone to spelling mistakes, and easier to send via email.

permalink_common_settings

Sometime back in April (2013), while listening to Mark Suster on This Week in Venture Capital, I heard him mention that one well know Search Engine Optimization (SEO) trick was to use full post names in the permallinks (http://baudlabs.com/sample-post/), as these were much better indexed by search engines such as Google. I gave it some thought and went ahead and made the change.

graph_summary_areachart_2013-01_2013-07

As you can see from the graph there was an immediate drop off in visits and page views right after the change. That’s expected, as almost all the URLs on the site have changed. Then the search engines reindexed the site and the daily visitor count started growing exponentialy, doubling in the first month and tripling in the second. It is very safe to say that the above described SEO trick works really well. On the same note, improved tag values seem to help with SEO as well. I am using a lot more tags now to describe each post.

On a final note, I am including a quote from the Google PageRank FAQ: “In general, webmasters can improve the rank of their sites by creating high-quality sites that users will want to use and share. Sites’ positions in Google search results are determined based on hundreds of factors designed to provide end-users with helpful, accurate search results.”

Posted in How To | Tagged , , , , , , , | Comments Off

How to create a WordPress widget plugin

This post is more of a resource list than a how to guide for creating WordPress widget plugins. Recently I have created my first WordPress custom widget, so I decided to publish here the list of resources I utilized in the development process.

Most of the technical documentation for the WordPress Widgets API can be found in the WordPress Codex. Another good source of information, turned out to be AwfulMedia’s “how to” walkthrough videos on YouTube. AwfulMedia has educational videos ranging from beginner friendly HTML/CSS tutorials to the more advanced videos including WordPress development. Austin of AwfulMedia has recently published a 3-part series called “Let’s Create a Basic WordPress Widget”, which I have embedded into this post below.

The are a couple of issues with the code Austin provides (at least in the latest version of WordPress), so I am including below a template based on his example for a simple widget. The basic steps to create a custom widget are the following: first, create a directory to host your plugin under /wp-content/plugins/ (in this example directory name is my-widget); then create a PHP file with the same name in this directory (my-widget.php). Here is the content of the my-widget.php file:

<?php
/*
Plugin Name: Hello World!
Plugin URI: http://baudlabs.com/how-to-create-a-wordpress-widget-plugin/
Description: This is a Hello world widget.
Version: 1.0
Author: Baud Labs
Author URI: http://baudlabs.com/
License: GPLv2 or later.
*/
class hello_world extends WP_Widget {
	function __construct() {
		parent::__construct(false, $name = __('Hello World!));
	}
	function form() {
	}
	function update() {
	}
	function widget($args, $instance) {
		?>
		<div class="widget hello_world">
			<p>Hello World!</p>
		</div>
		<?php
	}
}
function register_hello_world()
{
    register_widget( 'hello_world' );
}
add_action( 'widgets_init', 'register_hello_world');
?>

At this point in the process, the plugin will appear under the Plugins menu in WordPress and can be “Activated”. Once activated, it will appear as an Available Widget and can be added to your Theme.

Let’s Create a Basic WordPress Widget — Part 1

Let’s Create a Basic WordPress Widget — Part 2

Let’s Create a Basic WordPress Widget — Part 3

Once you create your widget, you may decide to share it with others by having WordPress.org host your plugin. You can add the plugin you’ve written to the WordPress plugin directory by submitting it here. This will give you access to a subversion repository where you can put your plugin. Please note that your plugin must use “GPLv2 or later” license in order to be considered for placement in the plugin directory. For additional info visit the WordPress Plugins Developer Center.

Posted in How To | Tagged , , , , | Comments Off

Broadcom’s BCM5357 single-chip 2.4G entry-level IEEE 802.11n retail router solution

Broadcom is a very popular chipset supplier, as far as wireless access points go. Broadcom BCM4702 powered the original Linksys WRT54G with Linux based firmware. As discussed briefly in the earlier post regarding current model open source routers, the chipset matters a lot when attempting to flash the router to open source firmware such as DD-WRT. Since a number of current model routers such as Netgear WNR300Lv2 and Linksys E1200 utilize the Broadcom BMC5357, I decided to look into the specs for this chipset.

Although Netgear WNR5300L claims to use a 480 MHz chip, everywhere else the BCM5357 clock speed is rated at 300 MHz. It’s a MIPS 74K architecture and has been on the market since May 2010. Supporting bgn wireless modes with 2×2:2 MIMO. According to WikiDevi there are currently 29 devices utilizing this chipset.

BCM5357

Here is the marketing info from Broadcom: Broadcom’s BCM5357 is a single-chip 2.4G entry-level IEEE 802.11n retail router solution. This wireless LAN (WLAN) router system-on-a-chip (SoC) solution has enhanced features, industry-leading performance and best-in-class power consumption. With this new Intensi-fi XLR SoC solution, Wi-Fi system OEMs can leverage unparalleled silicon integration to reduce the overall cost while still maintaining adequate multiple-input and multiple-output (MIMO) performance for streaming HD video throughout the home. Broadcom has optimized this new 802.11n router solution with its Accelerange technology for enhanced throughput and range performance along with advanced features that minimize power consumption for ‘green’ functionality modes.

  • Integrated IEEE 802.11n radio, media access controller (MAC), baseband, CPU, memory controller and 5-port Fast Ethernet switch.
  • Integrated 2.4 GHz power amplifier that has been proved in the field on shipping production platforms.
  • USB 2.0 host port for storage and print server applications.
  • Application and service support through NAND Flash and I2S PCM interface support utilizing Broadcom’s proven VoIP software stack.

Posted in Hardware | Tagged , , , , , , , , , , , , , , , , | Comments Off

Open source wireless access point (Wi-Fi) routers

Recently, one of my coworkers had asked me to recommend a good wireless router for home office use. Based on my past experiences, I suggested looking at products from Linksys and Netgear. It should be noted right away, that Cisco sold the Linksys business to Belkin earlier in the year, so I am not sure if the products and their support will get better or worse as time goes by. My colleague ended up buying the Netgear N300 Wireless Gigabit Router (WNR3500Lv2). While looking at the specs and features of this Netgear model, I noticed the bullet point advertising it as a “Open-source router for Linux developers and opensource enthusiasts” and a link leading to a community website (http://myopenrouter.com/).
wndr3500l_back
WNR3500Lv2 is a fairly good router with pretty decent Wi-Fi range. All ports are Gigabit Ethernet (including WAN, which matters if you are using 100+ Mbps FiOS), Broadcom BCM5357 480 MHz MIPS 74K processor, and 128 MB NAND flash and 128 MB RAM. Two neat hardware features that differentiate it from most other models on the market, are the power and wireless on/off buttons. Most other routers simply lack these. Returning to the topic at hand, the Netgear spec claims that DD-WRT, Open-WRT, Tomato and other popular Linux firmware is available for this model, which I have to admit did intrigue me. Serdar Yegulalp’s article in InfoWorld, 6 slick open source routers, is good overview of each firmware distro.

linksys_wrt54glI missed out on the whole open source Linux router phenomenon, which started with the release of the Linksys WRT54G a decade ago, for the simple reason that my home office has always been wired, so I had no need for a wireless router, that is until I bought my first tablet. Linksys WRT54G to this day is the most widely supported router in the open source community. As of this writing, Linksys is still marketing the WRT54GL model, which is an updated WRT54Gv4.

The current WRT54GL is powered by a Broadcom BCM5352 200 MHz processor, with 16 MB RAM and 4 MB Flash. The fact that it supports Wi-Fi up to 2.4 GHz 802.11g only, and has 4 MB Flash memory are a problem. The current full DD-WRT distribution (v24 preSP2 Mega) is nearing 8 MB, so it’s no longer possible to flash it on to WRT54GL. This is where the Netgear WNR3500Lv2 with its 128 MB NAND begins to shine. Stop Telling People to Buy WRT54GS was posted about a year ago by Nerd|Vent, and I completly agree with the argument that the WRT54GL hardware is completely outdated by today’s standards.

The Netgear WNR3500Lv2 uses a newer Broadcom chipset, so there is no “official” support for it in DD-WRT just yet. If Netgear actually continues to manufacture the router as it is, it should gain popularity with the open source community. Meanwhile, looking for current production model routers to use instead of the WRT54GL or the WNR3500Lv2, I stumbled upon Peter Zaborszky’s list of 5 Best Routers for DD-WRT with VPN. The list includes Linksys E1200 and E4200, D-Link DIR-632, Netgear WNDR3700, and Asus RT-N16. It should be noted that the Asus routers have been getting very high marks in most recent reviews.

Posted in Hardware | Tagged , , , , , , , , , , , , , , , , , , , , | Comments Off

Beware of the DHCP guard setting on Hyper-V virtual machines

I have been running Hyper-V 2012 in my lab for over a year now, and this is the first time that I have been caught off guard by the DHCP guard setting (no pun intended). DHCP guard drops DHCP server messages from unauthorized virtual machines pretending to be DHCP servers. As a precautionary measure, all of my lab VMs have the “Enable DHCP guard” and “Enable router advertising guard” checkboxes checked. In general this is a pretty good policy to follow, especially in the lab.

In this particular case, I have installed a DHCP server and configured a scope on VM1. Imagine my surprise when my client virtual machine (VM2) was not able to obtain an IP address via DHCP. After going over my DHCP settings twice, I finally remembered to go back to the Hyper-V host and check the DHCP guard setting. As soon as I unchecked the DHCP guard for the VM1, VM2 was able to obtain an IP address via DHCP.

Enable DHCP guard

Keeping in line with the fact that the whole world is now PowerShell, here are the cmdlets to make these changes via PowerShell. To “uncheck” the DHCP guard setting on the VM1 (from the above example), type the following PowerShell command:

Set-VMNetworkAdapter –VMName VM1 –DhcpGuard Off

To turn it back on:

Set-VMNetworkAdapter –VMName VM1 –DhcpGuard On

To view the status of the DHCP guard setting for VM1:

Get-VMNetworkAdapter –VMName VM1 | Format-List DhcpGuard

To enable DHCP guard for all virtual machines on a particular host (SERVER1 from our example):

Get-VM -Server SERVER1 | Set-VMNetworkAdapter -DhcpGuard On

RouterGuard allows you to specify whether the router advertisement and redirection messages from unauthorized VMs should be dropped. If you have a VM for which you want to allow router advertisement and redirection messages from unauthorized VMs, you can use the following cmdlet.

Set-VMNetworkAdapter –VMName VM1 –RouterGuard Off

For all other VMs, you can block router advertisement and redirection messages from unauthorized VMs with the following cmdlet.

Set-VMNetworkAdapter –VMName VM1 –RouterGuard On

For additional information take a look at the following TechNet articles:

Posted in Virtualization | Tagged , , , , | Comments Off

How to install Distributed File System (DFS) feature role in Windows Server 2012

DFS Namespaces (DFSN or DFS-N) and DFS Replication (DFSR or DFS-R) are role services in the Windows Server 2012 File and Storage Services role. Gary Olsen authored a pretty good article for Redmond Magazine on DFS best practices in Windows Server 2008 R2. The Distributed File System (DFS) in Windows Server 2012 is very different from the previous versions of Windows. First of all, it is important to note that DFS Namespaces and DFS Replication can be implemented independent of each other, as these serve two different purposes. Below is a quick overview of DFSN and DFSR:

DFS Namespaces — Enables you to group shared folders that are located on different servers into one or more logically structured namespaces. Each namespace appears to users as a single shared folder with a series of subfolders. However, the underlying structure of the namespace can consist of numerous file shares that are located on different servers and in multiple sites.

illustration_of_dfs_namespace

DFS Replication — Enables you to efficiently replicate folders (including those referred to by a DFS namespace path) across multiple servers and sites. DFS Replication uses a compression algorithm known as remote differential compression (RDC). RDC detects changes to the data in a file, and it enables DFS Replication to replicate only the changed file blocks instead of the entire file.

illustration_of_dfs_replication_group

The TechNet article “DFS Namespaces and DFS Replication Overview” may have it wrong, as I did not see a way to install DFS by using Server Manager. Windows PowerShell must be used to install DFS. To install DFS Namespaces, DFS Replication, and the DFS Tools portion of the Remote Server Administration Tools feature, in a Windows PowerShell session with elevated user rights type the following command:

Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication, RSAT-DFS-Mgmt-Con

Each feature can also be installed individually using the Install-WindowsFeature PowerShell command:

Role service or feature PowerShell name
DFS Namespaces (DFSN or DFS-N) FS-DFS-Namespace
DFS Replication (DFSR or DFS-R) FS-DFS-Replication
DFS Management Tools RSAT-DFS-Mgmt-Con

Install-WindowsFeature_RSAT-DFS-Mgmt-Con

Posted in How To, Management, Operating Systems | Tagged , , , , | Comments Off

Facebook as a search engine?

It’s been obvious to most for a while now, that Facebook is looking to get into the search engine business. Today I can confirm that that it is definitely the case. I was surprised to see a pike in my blog’s traffic analytics yesterday. Turns out the spike was caused by the Facebook Bot crawling and indexing my whole website, including all the pictures.

Facebook Bot statistics

Facebook definitely needs more ways to monetize their business [beyond selling users’ personal data to advertisers and government agencies], and search is a proven product that keeps bringing people back to the site. Besides the quality of the search results, I do see a few potential usability issues though. First of all, I do not want to login to do a simple web search. Second, I want a search page that loads quickly and does not provide any miscellaneous ads or info other than a search box. Google works this way and now we are all used to that. I am very much interested to see what Facebook will come up with.

Posted in Web x.0 | Tagged , , , , | Comments Off

PowerShell script to backup Hyper-V virtual machines (VMs)

While trying to come up with a simple method for backing up the virtual machines in my lab, I ended up creating the script below. In my particular scenario I have Windows Server 2012 Hyper-V running on a workstation with a multi-core processor, lots of memory, and plain old SATA hard drives. Since I am using Serial ATA II drives (SATA revision 2.0 – 3 Gbit/s – 300 MB/s), the obvious performance bottleneck is disk I/O. I will explain why this matters shortly, as I had to account for this in the script. The basic premise of the script is to backup the VMs to a different physical hard drive on the same host computer, and to have at least two full backups of each VM. Here is the script:

Remove-Item -Path F:\TempBackup -Recurse
mkdir F:\TempBackup

Stop-VM –Name LABVM1
Export-VM –Name LABVM1 –Path F:\TempBackup\
Start-VM –Name LABVM1
Start-Sleep -s 300

Stop-VM –Name LABVM2
Export-VM –Name LABVM2 –Path F:\TempBackup\
Start-VM –Name LABVM2
Start-Sleep -s 300

Stop-VM –Name LABVM3
Export-VM –Name LABVM3 –Path F:\TempBackup\
Start-VM –Name LABVM3
Start-Sleep -s 300

Set-Variable -Name DoM (Get-Date -Format dd)
IF($DoM % 2)
{Remove-Item -Path F:\OddBackup -Recurse
Rename-Item -NewName OddBackup -Path F:\TempBackup}
ELSE
{Remove-Item -Path F:\EvenBackup -Recurse
Rename-Item -NewName EvenBackup -Path F:\TempBackup}

In the script, first step is to create a temp directory (F:\TempBackup) to hold the current backup [if one already exists to delete it first]. Next steps are where each individual VM is stopped, exported to the temp directory, started, and then the script waits for five minutes (300 seconds) prior to proceeding with the export of the next VM. The reason for this pause is the disk I/O bottleneck I mentioned earlier. Five minutes provides more than enough time for the just backed up VM to boot without being affected by the very disk intensive export process [of the next VM in the script].

In the final steps, the script checks todays date and evaluates whether it is Odd or Even (July 27 = Odd, July 28 = Even). Depending on the date the existing Odd (F:\OddBackup) or Even (F:\EvenBackup) backup directory is deleted and the temp directory (F:\TempBackup) is renamed to it. The reason for using a temp directory is to ensure that the backup completes successfully first, prior to overwriting the existing backup. In cases where the script is interrupted and does not complete, the previously completed backup remains safe and sound.

PowerShell script to backup Hyper-V VMs

Please note that during the backup process there are three copies of each VM (Odd, Even, and Temp), so free disk space on the backup drive must be sufficient to accommodate this. In other words if your VMs take up 100 GB, your backup drive should be at least 300 GB in size (100 GB for Odd, 100 GB for Even, and 100 GB for Temp). Also, note that if you are planning to backup the VMs to another host or network storage location, my recommendation is to export to a local temp directory first and then transfer the backup to its final destination. Exporting a Hyper-V VM to a network location [over a gigabit network] can take ten times as long as exporting the same VM to local disk.

Posted in Management, Virtualization | Tagged , , , | Comments Off

How to improve Internet connection performance by selecting the fastest DNS servers

In a lot of cases the Internet connection performance can be improved by using DNS servers different from the ones supplied by the ISP. How do we know that using Google Public DNS will improve performance? We don’t. Not unless we test it. DNS Benchmark and Namebench are two free utilities that are available to aid us in this task. Both are great troubleshooting tools and are a must have for every network admin’s toolset. This post provides a very general overview of the two products.

dns_benchmark_screenshot1

DNS Benchmark is free utility from Steve Gibson of Gibson Research Corporation (GRC) fame. This is one of many great utilities that Steve has developed. It’s a tiny 164 KB standalone executable compared to the 5 MB compressed setup for Namebench. On the other side Namebench has already been ported to Linux and MacOS.

dns_benchmark_screenshot2

DNS Benchmark’s DNS server ranking methodology is slightly different from Namebench’s, as clearly indicated by the results of two consecutive tests using both products. DNS Benchmark recommended Level 3 (4.2.2.5) and Speakeasy (216.254.95.2) DNS servers. Namebench recommended UltraDNS (156.154.70.1) and Genuity/Level 3 (4.2.2.6).

namebench_screenshot1

Namebench benchmarks DNS server responses for your Internet connection utilizing a number of selectable options and generates a detailed report in HTML format. I am including screenshots of the report below to give a better idea of the results. In this particular case UltraDNS returned faster results than Google Public DNS (8.8.8.8, 8.8.4.4) which are my current preferred DNS servers.

namebench_screenshot2

namebench_screenshot3

namebench_screenshot4

namebench_screenshot5

Granted the above applies mostly to small office/home office (SOHO) Internet connections, as most enterprise environments will have their own DNS server infrastructure in place. Another interesting point to note is that DNS cache plays a huge role in Internet connection performance. Given two identical DNS servers — one with few users querying it and one with many, the one with many will provide quicker responses because most of its DNS lookups will already be cached. This holds true until the number of users or DNS queries gets so large that the server is not able to respond due to network I/O or processor performance bottlenecks.

Posted in How To, Management | Tagged | Comments Off