Category Archives: Uncategorized

Don’t ever put CNAME on the root domain (esp. if you want MX to work)

I was changing name servers for one of my domains. When testing the mail setup, I kept getting mail sent to the web server rather than the mail server. It turns out that if the mail server can’t find mx records, it falls back to A (or CNAME) records. So why was the mail server falling back to using the A/CNAME record when I had a perfectly good MX record assigned to the domain? After many hours of debugging and comparing working domain with non-working ones, the only difference I found was that I has a CNAME for the domain eg.

domain.com. 3600 IN CNAME www.domain.com

Turns out that if you have a CNAME for the domain, it redirects the lookup not just for A but for every record. So from dig, it looks fine if you query the authorative name servers directly – you see the mx and cname record – but it falls flat when queried on the recursive nameserver. Indeed after looking at RFC 1034, it states that “If a CNAME RR is present at a node, no other data should be present”. So setting the CNAME on the domain also consequently redirected requests for NS and SOA records, which made the domain quite invalid, although the subdomain records still resolved. Bottom line, don’t ever put CNAME on the root domain.

I was trying to be smart and save on retyping the IP by using CNAME… but turns out I was too smart.

How to use the WAN port on WRT54G or WRT610n as a LAN port

I have a WRT54G at home but I don’t use its routing capabilities, only wireless and LAN. There are only 5 ports on the device and one is dedicated as the WAN port. I want to turn the WAN port into a LAN port so I can make use of all 5 ports. How do you do it? As long as you have shell access (obtained by telnet on custom firmwares like dd-wrt or openwrt), just type in these commands:

For WRT-54G

nvram set vlan0ports="0 1 2 3 4 5*"
nvram set vlan1ports="5"
nvram commit

For WRT-610N:

nvram set vlan1ports="0 1 2 3 4 8*"
nvram set vlan2ports="8"
nvram commit

Then reboot the router. What we’re doing is assigning the (former) WAN port (0) to the LAN vlan, instead of the WAN vlan.

Pocket PC/Windows Mobile 2003 and new daylight savings

If you are living in an area which just had daylight saving changes (i.e. Australia), you may find that your Windows Mobile need updating to the new DST rules. Microsoft only seems to provide patches for WM 2005 and up, so unfortunately for those with 2003, you’re left with a confused clock which can’t properly tell when DST begins and ends. Me being an owner of one of these, I scoured the net looking for a way to manually correct this. If you are on normal Windows, there is a utility called tzedit.exe which allows you add change timezone and DST rules. However, it doesn’t look like it exists for the PPC.

In Windows, timezones are stored in the registry and sure enough, same applies to PPC, except it is in a different format. The default registry doesn’t store any timezones and it only reads the registry for overrides. The registry key in which the timezone overrides reside is HKLM\SOFTWARE\Microsoft\Timezones, under that you have put each timezones as a separate key named with a timezone id. Timezone ids are cryptic. 255 corresponds to Sydney for example. A full list is avaliable on the page. Creating a new registry key 255 (or another time zone number) and setting the TZI binary variable to the same value as TZI on a desktop Windows (with correct rules) should allow your PPC to understand the new time zone daylight saving rules.

The longest and shortest days of the year

You would think everyday of the year has twenty-four hours right? That’s what I thought while writing a typical function to calculate the time difference between two dates. As I found out, especially in this time of year, this is a horribly flawed assumption. In a lot of timezones, one day of the year has 23 hours while another day has 25 hours. Some of you might have gathered by now that I’m talking about Daylight Saving Time. The marvellous invention, epitome of temporal manipulation that makes it so that this Sunday, there would be only be one hour between 1AM and 3AM. In summary, 3-1 = 1. Those of you on northern hemisphere will find that you will experience 2AM twice.

Once upon a time, I used to a backup cron job that runs on 2AM. 2AM seems to be a nice time as everyone is asleep so that the server could use the spare processing power for the menial task. In one day of the year it ran twice. In one day of the year it never ran. Now all my backups run at 4AM.

As a programmer, I hate DST.