If you are planing on buying a 3G iPhone for unlocking, DON”T, at least not until you read more.
As of right now, there is no way to unlock a brand new 3G iPhone. The newest iPhones have version 2.2.1 firmware, which was released at the end of January. The 2.2.1 firmware includes included an update (02.30.03) to the “baseband” firmware (the chip that makes the iPhone a phone) that breaks the unlock.
Older 3G iPhones can be updated to the 2.2.1 firmware using a special process that preserves the older, unlockable, baseband, but chances are, unless the iPhone has been sitting on the shelf for a month, any newly purchased iPhone will have to wait for an update to yellowSn0w that works with the newest baseband firmware.
If you have an older 3G with 2.2 firmware, you’ll have to use the Mac-only PwnageTool to prepare a custom firmware image with the old baseband. Unfortunately, if you have a newer 3G iPhone, there is no way to roll-back to the older baseband firmware.
Again, as of early March, new 3G iPhone’s can’t be unlocked until the iphone dev team releases an unlocker that supports the 2.2.1 firmware with the 2.30.3 baseband firmware.