Using cfgadm to display LUNs on Solaris hosts

If you are trying to configure and unconfigure LUNs on a Solaris host, you may be suprised to find that the default ‘cfgadm -al’ output doesn’t display the LUNs on your system. To view the LUNs on a Solaris host, you need to use cfgadm’s show_SCSI_LUN option:

$ cfgadm -al -o show_SCSI_LUN

Ap_Id                          Type         Receptacle   Occupant     Condition
c3                             fc-fabric    connected    configured   unknown
c3::50060161082006e2,0         disk         connected    configured   unknown
c3::50060161082006e2,1         disk         connected    configured   unknown
c3::50060161082006e2,2         disk         connected    configured   unknown
c3::50060161082006e2,3         disk         connected    configured   unknown
c3::50060161082006e2,5         disk         connected    configured   unknown
c3::50060169082006e2,0         disk         connected    configured   unknown
c3::50060169082006e2,1         disk         connected    configured   unknown
c3::50060169082006e2,2         disk         connected    configured   unknown
c3::50060169082006e2,3         disk         connected    configured   unknown
c3::50060169082006e2,5         disk         connected    configured   unknown
c4                             fc-fabric    connected    configured   unknown
c4::50060160082006e2,0         disk         connected    configured   unknown
c4::50060160082006e2,1         disk         connected    configured   unknown
c4::50060160082006e2,2         disk         connected    configured   unknown
c4::50060160082006e2,3         disk         connected    configured   unknown
c4::50060160082006e2,5         disk         connected    configured   unknown
c4::50060168082006e2,0         disk         connected    configured   unknown
c4::50060168082006e2,1         disk         connected    configured   unknown
c4::50060168082006e2,2         disk         connected    configured   unknown
c4::50060168082006e2,3         disk         connected    configured   unknown
c4::50060168082006e2,5         disk         connected    configured   unknown

Finding words with look

If you have ever had a moment when you couldn’t recall a word from memory, but knew something about the word, you probably wandered to one of the numerous online dictionaries to find the name. If you happen to have a Solaris box handy, you can avoid the web and use the look utility to find the word. Look is run with a string that you want to match to a word, and it uses the word list in /usr/share/lib/dict/words during the comparison. The following examples show this nifty utility in action:

$ look liti
litigant
litigate
litigious

$ look oth
Othello
other
otherwise
otherworld
otherworldly

Using BIND to reduce ad server content

Internet advertising has become big business, and we see the effects of it in almost every page we view. The ad content typically comes from one or more well known ad servers, and some folks have come up with some clever ways (e.g., hosts files, DNS integration, etc.) to minimize the “ad effect” in the content we view. I have been using Mike’s host file for quiet some time, but for some reason OS X (actually lookupd) doesn’t handle large hosts files real well. Since OS X would get bogged down during DNS resolution, I decided to merge all of the ad domains into DNS to centrally fix the problem for the clients I support.

This was super easy to do, and only required two steps (assuming you are already running bind). The first step is to add one “zone” statement to named.conf for each ad domain you want to nix. The following example shows the named.conf entry you would add for the ad domain adservers.com:

zone "adservers.com" 
{ 
       type master; notify no; file "master/null.zone"; 
};

You can get a comprehensive list of the well known ad server domains from the ad blocking website. Once you retrieve the list, you can merge the domains into the named.conf using a combination of shell utilities, or you can download the Perl script (updateads.pl) I wrote to automate this process. The Perl script grabs the latest host file from the ad blocking website, formats the data, and spits out several lines that can be appended to named.conf:

$ updateads.pl |more

// *** Added domains on Thu May 25 13:53:34 2006 *** //

zone "ad1.com" { type master; notify no; file "master/null.zone"; };
zone "ad2.com" { type master; notify no; file "master/null.zone"; };
zone "ad3.com" { type master; notify no; file "master/null.zone"; };
[ ..... ]

Once you add all of the domains to named.conf, you need to create a zone file with one wildcard A record (this record is what is used to remove the ad servers, since the wildcard record will translate all entries in a given domain to 127.0.0.1). I am currently using the following zone file (with different domain names) to implement my ad blocking solution:

; File: null.zone
; Last modified: 07-10-2005

$TTL    86400   ; one day

@       IN      SOA     ns.mydomain.com      hostmaster.mydomain.com. (
                        2005071005       ; serial number YYYYMMDDNN
                        28800   ; refresh  8 hours
                        7200    ; retry    2 hours
                        864000  ; expire  10 days
                        86400 ) ; min ttl  1 day
                NS      ns.mydomain.com.

                A       127.0.0.1

*               IN      A       127.0.0.1

I have found that using this technique speeds up the time it takes to render a page, enhances privacy, and will also cut down on the amount of traffic consumed by your site. Tis good stuff!

Splitting files with csplit

Periodically I find that I need to split a file into several pieces. There are a number of utilities that can be used to split a file, but I have grown to adore csplit. Csplit can split files based on regular expressions, or by quantity. The following example uses csplit to split /etc/services into a series of 10-line files:

$ csplit -f services.bak.00 /etc/services 10 {10}

172
208
225
372
408
188
450
392
256
325
434
521

$ ls -la service*

-rw-r--r--   1 root     root         172 May 24 12:36 services.bak.0000
-rw-r--r--   1 root     root         208 May 24 12:36 services.bak.0001
-rw-r--r--   1 root     root         225 May 24 12:36 services.bak.0002
-rw-r--r--   1 root     root         372 May 24 12:36 services.bak.0003
-rw-r--r--   1 root     root         408 May 24 12:36 services.bak.0004
-rw-r--r--   1 root     root         188 May 24 12:36 services.bak.0005
-rw-r--r--   1 root     root         450 May 24 12:36 services.bak.0006
-rw-r--r--   1 root     root         392 May 24 12:36 services.bak.0007
-rw-r--r--   1 root     root         256 May 24 12:36 services.bak.0008
-rw-r--r--   1 root     root         325 May 24 12:36 services.bak.0009
-rw-r--r--   1 root     root         434 May 24 12:36 services.bak.0010
-rw-r--r--   1 root     root         521 May 24 12:36 services.bak.0011

Tis good stuff!