Archive for January, 2006

Using a Bluetooth headset with the IBM T42P

Monday, January 16th, 2006

It turns out that getting my new Bluetooth headset working correctly with my IBM T42P notebook computer was more complicated than expected. The factory-shipped Bluetooth configuration is unusable with some devices, including my headset. Here’s the story, including how to fix it:

When I first set up the wireless headset last week, I paired it with my Nokia 6820 cell phone, which already has a working Bluetooth stack and handsfree device profile for using a headset. I was also able to successfully initialize device pairing with the notebook computer and the cell phone at the same time, which was one of the main selling features of the Plantronics 510. The headset showed up in the Bluetooth devices list, as expected, and I didn’t get around to trying to use it until today.

The headset has been working great for handsfree phone use, so today I was looking forward to trying it with some voice applications on the notebook computer.

It turns out that while the Bluetooth headset successfully paired with the T42’s built-in Bluetooth (IBM Integrated Bluetooth III), none of the headset device interfaces were recognized and initialized by the system (WinXP SP2 Pro). This means that in the Control Panel, the audio devices corresponding to the headset microphone and earpiece didn’t show up, so they were unselectable for use in applications.

From investigating this, it looks like:

  1. IBM supplies a Bluetooth stack (Widcomm) specific to their hardware, and Microsoft also provides a Bluetooth stack with WinXP SP2.
  2. If both are running, the results are unpredictable. In my case, the Nokia 6820 was able to connect without problems with both stacks in place, but the Plantronics 510 paired without loading the interfaces, making it useless.
  3. Under most conditions, when WinXP detects new Bluetooth hardware, it will automatically load the Microsoftc Bluetooth stack.
  4. If the Microsoft Bluetooth stack isn’t loaded, 3rd party Bluetooth stacks can still be installed and provide identical or enhanced functionality.

Here’s a solution that worked for me (although I still don’t entirely understand the problem interaction yet):

  1. Remove all instances of Bluetooth stacks in the Device Manager.
  2. Before rebooting the system, prevent the Microsoft Bluetooth stack from loading. Here are the instructions from Microsoft’s knowledge base KB889814:

    1. Click Start, click Run, type sysdm.cpl, and then click OK.
    2. Click the Hardware tab.
    3. Click Device Manager.
    4. Expand Bluetooth Radios.
    5. Right-click each device listed under Bluetooth Radios, click Uninstall, and then click OK.
    6. Close Device Manager, and then click OK.
    7. In Windows Explorer, open the C:\Windows\Inf folder.
    8. Rename the Bth.inf file to Bth.inf.old.
    9. Rename the Bth.pnf file to Bth.pnf.old.
    10. Restart Windows XP SP2.

  3. Now reboot the system. Windows XP will detect the Bluetooth hardware and begin automatically installing the drivers. This time, the IBM Bluetooth software will be installed, but without loading the Microsoft Bluetooth software.
  4. At this point, the Control Panel item for Bluetooth Configuration will actually work, and there will be many tabs that weren’t there before. The Bluetooth Devices applet appears to do nothing, I think it may be left over from the Microsoft stack.

There are several lengthy discussions on Bluetooth and IBM T series notebook computers over at the thinkpads.com forum. This one is probably the most relevant, but be sure to read to the end, since the first post on the thread is from March 2005, and all the software involved has been updated since then.

After disabling the Microsoft Bluetooth stack and rebooting, I needed to reinitialize the device pairing to connect the cell phone and the headset, but since then everything seems to be working OK.

This is remarkably “user-unfriendly” and about as far from “plug and play” as I can imagine.

A temporary .htaccess rewrite fix for Ultimate Tag Warrior and Wordpress 2.0

Saturday, January 14th, 2006

I’ve been using this blog and my running blog for testing out Wordpress 2.0 before trying things out on the main site. This evening’s task has been setting up tagging on my running blog. I’ve been using Jerome’s Keywords for a while, but have been reading good things about Christine Davis’ Ultimate Tag Warrior and decided to give it a try.

Ultimate Tag Warrior is extremely comprehensive and flexible. There are versions for both Wordpress 1.5.x and Wordpress 2.x, although I’m only working with the later version. The plugin works smoothly after being activated, and the only tricky part has been that URL rewrites are different in Wordpress 2.x. — rewrites are now done within Wordpress rather than in the .htaccess file, which seems like a good idea, but in the meantime this plugin and others are still a little in transition.

As currently shipped, the plugin automatically generates rel=”tag” links for Technorati, and can be configured to point to other tag services or use local tags. The URL rewrite problem breaks “clean URLs” for local tags of the form http://site/tag/localtagname, so if you just want to generate Technorati tags you’re already in good shape. Without working URL rewrites, other features like local tag clouds don’t work so well though.

In the meantime, here’s a temporary fix (from comments posted by Stephen Collins) which can be added to the .htaccess file in the root directory of the Wordpress installation. The example here is for http://www.hojohnlee.com/running/, you should change the paths to match your own.

This fix is unlikely to be needed for very long, there is a lot of activity underway among Wordpress plugin developers to get things working with the new version. If you put this in place, you should probably keep an eye on the Ultimate Tag Warrior page or the Wordpress support forums for updates.

# UTW

RewriteEngine On
RewriteBase /running/
RewriteRule ^tag/?(.*)/feed/(feed|rdf|rss|rss2|atom)/?$ /running/index.php?tag=$1&feed=$2 [QSA,L]
RewriteRule ^tag/?(.*)/page/?(.*)/$ /running/index.php?tag=$1&paged=$2 [QSA,L]
RewriteRule ^tag/?(.*)/$ /running/index.php?tag=$1 [QSA,L]
RewriteRule ^tag/?(.*)/page/?(.*)$ /running/index.php?tag=$1&paged=$2 [QSA,L]
RewriteRule ^tag/?(.*)$ /running/index.php?tag=$1 [QSA,L]

Update 02-08-2006 22:30 PST:
After upgrading to Wordpress 2.0.1, it looks like this fix for .htaccess is still needed with the version of Ultimate Tag Warrior that I’m currently using (2.9.2.1) over on my running blog.

Wordpress 2.x has moved the URL rewriting out of .htaccess and mod_rewrite and into classes.php. This provides access to more hooks forl plugin developers in the future, but in the meantime this seems to be causing a lot of problems with non-standard permalink structures or custom rewrite rules.

What (spam) sites are at that IP address?

Saturday, January 14th, 2006


Here’s a handy way to check out what sites are associated with an IP address:

A2B has recently implemented ping blocking to reduce the volume of spam hitting their geotagged search engine. They publish a current list of blocked IP addresses, and you can also submit queries to see what sites have been seen recently at a given IP address.

Here’s the list of sites from an identified spam IP address (70.86.36.194). They also list the blogs associated with the IP address.

Many of the blocked sites are submitting 6000 to 8000 pings per day. A2B reduced their ping traffic from 27GB to 6GB daily by blocking the 112 top spam blog IP addresses turning up in their server logs.

The lookup service is a little similar to some of the reverse DNS services that are available (IP to domain name), but it appears to have a shorter time horizon. A quick check on some sites I know to be on shared hosting services only shows some of the sites that are at their respective IP addresses.

via SpamHuntress, see also comments there from Sam Critchely of A2B.

Blocking spam domain referrals with .htaccess

Thursday, January 12th, 2006

After a few weeks of relative quiet on the web spam front over the holidays, I see that there’s been a huge uptick in new spam referrers turning up in the server logs here. I suppose the spam operators have come back from the holidays as well.

Referrer spam is fairly pointless on my site, since I don’t publish automatic lists of site referrers. However, it can chew up a lot of bandwidth and CPU cycles.

The first line of defense here is using .htaccess to completely block the top level domains and IP addresses that are known to be problematic. Additional filtering is done by individual applications such as Wordpress (Akismet et al) but if you block unwanted traffic with .htaccess you don’t even generate the web page. This is of particular interest to Dreamhost users, where they seem to have started tracking CPU use more closely.

The method shown here will work on Dreamhost and most other hosted services that allow user defined .htaccess files. Here’s the general approach. In .htaccess, we define the “bad referrer” patterns, which will match the incoming HTTP Referer field. If the BadReferrer variable is set, then we block that request, sending back an HTTP 403 response.

SetEnvIfNoCase Referer ".*.baddomain.com" BadReferrer
SetEnvIfNoCase Referer ".*anotherbaddomain.com" BadReferrer

order deny,allow
deny from env=BadReferrer

The patterns used in .htaccess are regular expressions, which can be a little hard to read. It’s important to precede the “.” in domain names with a “\”. It’s a good idea to save a working copy of .htaccess before you start editing it, since you can make your entire site inaccessible if you accidentally create a pattern that blocks all referrers rather than the unwanted ones. The first case shown above will block “www.baddomain.com”, while the second will block “anotherbaddomain.com”. See the Apache documentation for more complete information on using .htaccess.

Here’s the htaccess blocklist rules I’m currently using to keep out spam domain referrals. The patterns don’t exactly match real domains in all cases, as wildcards are used occasionally to catch variations of the same domain name. (Warning — many of the domain names are predictably offensive.)

If have specific IP addresses that you want to block, you can also define that here:

deny from 10.0.0.1

Blocking individual IP addresses is less useful, since most spam traffic seems to originate from networks of hijacked PCs, with IP addresses all over the world that change frequently. That said, there also seem to be individual spammers who are running spamming applications on their personal computers, which are pretty easy to block in .htaccess.

Here my previous notes on referrer spam:

Plantronics Voyager 510 Bluetooth Headset

Tuesday, January 10th, 2006

plt-510-and-nokia-6820
I recently decided to give another try to using a Bluetooth headset, and this time around I’m quite happy. I last tried using a Bluetooth headset a few years ago and was unimpressed, both by the high price and by the poor usability. My usual handsfree solution since then has been to use the speakerphone mode on my phone. This works well in the car if you’re by yourself, but can be problematic if others are riding with you.

I wanted a headset that would work with my Nokia 6820 as well as voice applications on my notebook computer, and found the Plantronics Voyager 510, which is able to pair with two devices supporting either the Bluetooth handsfree or headset device profile. The sound quality is good, comparable to a wired headset, it’s comfortable enough to leave on for hours at a time, and the battery life lasts more than a day. The wireless connection works from my desk to anywhere in my office, I’ve tried it to 15-20 feet or so, and also stays connected if I leave the phone in the car and walk around to fill the gas.

The headset can be set up for use on either the right or left, and comes with three eartips of different sizes along with a pair of microphone windscreens.

I’ve been using the headset for the past few days, including several hours of driving between Palo Alto and Los Angeles, and so far am impressed with the improvement over the early Bluetooth headsets, which were expensive, bulkier, sounded worse, and didn’t work well with the cell phones. This may push me back in the direction of getting a smarter phone / PDA device again.

Opening up SSH and HTTP ports using iptables from the command line

Thursday, January 5th, 2006

I have to look this up from time to time, usually just after installing a new Linux system intended for use as a test server. There are GUI tools for configuring the firewall, but I usually leave the entire windowing system uninstalled.

By default, many Linux distributions will start up sshd and httpd, but you won’t be able to connect to them over the network, since the ports will be blocked by iptables. The examples below are for Red Hat or CentOS (which is basically Red Hat), and may vary slightly betweenl distributions.

To see the current iptables firewall rules, use iptables –list (that’s two dashes):

[root]# iptables --list
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     ipv6-crypt--  anywhere             anywhere
ACCEPT     ipv6-auth--  anywhere             anywhere
ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:5353
ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

The part we’re interested in is the “RH-Firewall-1-INPUT” list. We need to add two rules, which will accept incoming TCP connections to port 22 (sshd) and port 80 (httpd).

[root]# iptables -I RH-Firewall-1-INPUT 3 -p tcp -m tcp --dport 22 --tcp-flags SYN,RST,ACK SYN -j ACCEPT
[root]# iptables -I RH-Firewall-1-INPUT 3 -p tcp -m tcp --dport 80 --tcp-flags SYN,RST,ACK SYN -j ACCEPT

The additions will now appear in the output of iptables –list:

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http flags:SYN,RST,ACK/SYN
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh flags:SYN,RST,ACK/SYN
ACCEPT     ipv6-crypt--  anywhere             anywhere
ACCEPT     ipv6-auth--  anywhere             anywhere
ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:5353
ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

You can now connect to the server over the network. Unfortunately, this will only last until it’s rebooted. To save the iptables configuration, do something like:

/etc/init.d/iptables save

This will update the saved configuration in /etc/sysconfig/iptables, which will be used to initialize iptables at boot time.

Discount code at Voxilla for Asterisk users

Thursday, January 5th, 2006

I’m picking up yet another Sipura SPA-2002 over at Voxilla. The discount code for Asterisk users is “*user”, good for 5 percent off.

The SPA-2002 is a two line analog line adapter for VOIP. I’ve been using a combination of VoicePulse on one line and Asterisk on the other, although I’ve been debating running everything through the Asterisk server, which is presently handling private traffic only.

Tactical hacking?

Sunday, January 1st, 2006

I’m going to try setting up a space for tech-oriented posts that might otherwise be too obscure, mundane, or generally not fit in over at the main site. I suppose I could think of these as “tactical hacks” as opposed to “strategic hacks”, but it’s just as likely to provide a home for notes on dealing with Wordpress or whatever randomly flawed equipment I’ve encountered.