First you need to jailbreak your device. Then make sure your baseband version
[1] matches a version that is supported to be unlocked. Then open Cydia (this has been installed by the jailbreak tool) and search for ultrasn0w. Install it. Your device will reboot afterwards.
Supported baseband versions of current ultrasn0w:
- for iPhone 3G/3GS: baseband 5.13.04 or lower (or the iPad baseband 6.15.00)
- for iPhone 4: baseband 1.59.00
- for iPad: baseband 6.15.00
If you install ultrasn0w on a not compatible baseband, you will get "No Service" all the time, even with your original carrier SIM.