I strongly recommend you backup your iPhone via iTunes BEFORE you begin this guide.
Step 2 Upgraded your iphone 3G/3GS to 3.0 firmware via iTunes, jailbreak the iphone using redsn0w, install cydia or icy.
Step 3 After your iPhone is jailbroken and installled either cydia or icy, run cydia or icy, add the repo repo666.ultrasn0w.com to cydia or icy. Search for “ultrasn0w” and install it. Reboot your iPhone. Your iPhone is unlocked and you are done.
Step 4 If you want to unlock the phone temporarily when you travel only, you need to install "BossPrefs" and "BossPrefs UltraSn0w toggle for Bossprefs" in cydia or icy. Simply search for the term "BossPrefs" and "BossPrefs UltraSn0w toggle for Bossprefs" and install both of them. You will have an icon "BossPrefs" on your springboard.
Trap "BossPrefs", and you will see few toggles, you can turn on and off the ultrasn0w and other functions.