1. Jailbreak your iPhone 3G (or first gen iPhone running the 2.0 software). Install OpenSSH via Cydia.
2. Create an ad-hoc network on your computer. On Macs, just click on the Wi-Fi icon in the menubar and select "Create Network." On Windows, set up internet connection sharing.
3. Join the iPhone to this network via Wi-Fi as usual.
4. On the iPhone, under Settings->Wi-Fi, select the network you have joined to view connection details. Write down its IP address.
5. From the Mac's Terminal, run the following command:
ssh -ND 9999 root@IPHONE_IPADDR
but replace IPHONE_IPADDR with the IP you wrote down in step 4. Login. The default root password is
alpine; you should really login normally over SSH and change this.
Windows users: the free SSH client Putty will allow you to accomplish this same step. Don't install Cygwin+OpenSSH as some suggest, that's massive overkill.
7. Surf. I've successfully done web browsing and IRC, anything that supports SOCKS4/5 should work. Haven't yet had success with my Citrix client :(
For the curious: The iPhone is joining your Wi-Fi network, but with no internet access on this network it falls back to using 3G for outgoing packets.
ssh -NDcreates a local proxy server that relays packets from the loopback address on your pc to the iPhone, which dutifully proxies them out the cellular connection.
Browsing is surprisingly fast, 3G really shows its potential here. It's zippier than doing it directly on the iphone, which I put down to rendering delay.
A more ideal solution of course would be to get the iPhone showing up as a regular access point. I see no reason why this wouldn't be possible, and will be doing some research myself, mostly observing what Unix processes handle this on desktop OS X, and see if they can be compiled from source for the iPhone. In the meantime, the steps to accomplish this are not bad and will definitely serve in a pinch.
Thanks Jewdass and Lifehacker for this one! You made some Fan Boys very happy today!