Thanks to the iphone dev team there are two ways to achieve that very easily (also be sure to read the notes carefully for each of the two programs!):
Both ways will only jail break, your device, to unlock your iPhone you will also need ultrasn0w, which later can be installed via Cydia, once you completed the jailbreak.
redsn0w is more like Quickpawn, if you remember/know that, so that is the easiest and fastest way:
- Upgrade your iPhone 2G/3G via iTunes to iPhone OS 3.0
- download redsn0w
- run redsn0w
That´s about it! Enjoy!
Remember: jailbreaking / unlocking your device might void your warranty! You do that on your own risk, if your iPhone breaks, we are not resposible for that!