Below are the instructions on how to unlock the iPhone 4, iPhone 3GS, and iPhone 3G for use with any GSM carrier using Ultrasn0w. This will work with the iOS 4.2.1 firmware if you are on the 06.15.00 baseband.

Note : The jailbreaking tutorial is below.

Requirements :

* Jailbroken iPhone
* Baseband : 04.26.08, 05.11.07, 05.12.01, 05.13.04, 06.15.00, or 01.59

Note : If you are on T-Mobile, turn off 3G before starting.

Unlock iPhone 4, 3GS, 3G Using Ultrasn0w [How To] :  

1) Launch Cydia > Manage > Sources.

2) If the Ultrasn0w repo is not present, press the Edit > Add > Enter as the source url and press the Add Source button.

3) Select from the list of user entered sources.

4) Select ultrasn0w from the list of packages

5) Select Ultrasn0w > Install > Confirm.

6) After installation completes successfully press the large Restart Springboard button.

You should now be able to insert the SIM of your choice.

If you have any queries, feel free to ask in the comments section below.