The iPhone Dev-team has managed to provide a working unlock and jailbreak solutions for iPhone 3G and 3GS, just a week after the iOS 4.2.1 firmware releases. They first released Redsn0w 0.9.6 b4 untethered/ tethered jailbreak. And then PwnageTool 4.1.3 and Redsn0w 0.9.6 b5 unlock tools for Mac and Windows. Currently, these iOS 4.2.1 unlock works with iPhone 3G and 3G S models with baseband higher than 05.14.02. They use iPad OS 3.2.2 to upgrade the modem firmware of the target device to 06.15.00, so that it is compatible with Ultrasn0w 1.2 unlock through Cydia.
You can choose the the required unlocking method based on your operating system platform. In all case, you first need to jailbreak your iPhone 3G or 3G S with Redsn0w 0.9.6 b4.
Download iPad OS 3.2.2 here.
Download PwnageTool 4.1.3 here.
Follow the instructions given given here to unlock iPhone 3G or 3G S (iOS 4.2.1)with Ultrasn0w 1.2.
Download Redsn0w 0.9.6 b5 and follow the unlock instructions here.
Please check your iPhone 3G/3G S modem firmware version after PwnageTool 4.1.3 or Redsn0w 0.9.6 b5 flashing. If it is 06.15.00, you may directly go for Ultrasn0w 1.2 unlock via Cydia.