Total Pageviews

Saturday, 31 December 2011

Use Your iPhone’s Internet Connection On Your Laptop(利用已联网的iphone来让笔记本上网)

It's great that your iPhone has a data plan and a killer mobile browser, but when you're sitting at the airport waiting to catch a plane with your laptop right next to you, wouldn't it be nice to use your full-on desktop browser? Out of the box your iPhone won't allow you to tether your EDGE data connection to another computer wirelessly, but with a little ingenuity on your part you'll be browsing the net on your laptop through your iPhone's data service in no time.
NOTE: You're probably asking yourself: "Isn't the EDGE data network that the iPhone uses SLOW?" Well, yes it is. But if you're at all like me, sometimes a slow full-screen browsing session is better than slow browsing on the small screen.
I've only tested this method on my MacBook Pro, but since SSH is platform independent, this should be a workable solution on Windows, Mac, or Linux.

What You'll Need

For this guide, you'll need:

Prepare Your iPhone

Use Your iPhone's Internet Connection On Your LaptopAssuming you've already got Installer.app installed on your iPhone (which you will have installed if you've gone through the jailbreak mentioned above), the first thing you need to do is install OpenSSH. So head to your iPhone's home screen and fire up Installer.app. Now go to the Install tab and tap on System -> OpenSSH and tap the Install button. Once it installs, exit Installer.app.

Start Up Your Ad-Hoc Network

This process differs depending on what operating system you're using. As I said above, I've only tested this on a Mac, but I'll point to instructions on how to do the same on Windows as well.
Use Your iPhone's Internet Connection On Your LaptopIf you are using a Mac, just click the Airport icon in your menu bar and click on Create Network. Then just give your network a name and—if you like—a password.
On a Windows PC you'll need to set up Internet Connection Sharing. You can find instructions for doing so here. Good luck!
Once you create your network, your computer won't be able to connect wirelessly to any Wi-Fi hotspot, just other devices.

Connect Your iPhone to Your Computer

Use Your iPhone's Internet Connection On Your LaptopTo get your computer and iPhone talking, you'll need to connect your iPhone to the ad-hoc network we created above. To do so, go to the Settings application, tap Wi-Fi, and select your ad-hoc network from the list of available networks.
Use Your iPhone's Internet Connection On Your LaptopOnce you're connected, tap the blue arrow next to your new network to get info on your connections—namely your IP address. Write that puppy down because you'll need it in a second.

Connect Your Computer to Your iPhone's Internet

Now it's time to make use of the SSH server we installed on our iPhone. From this point on, we're basically following our previous guide to encrypting your web browsing with an SSH SOCKS proxy. Open up your command line application of choice and enter the following:
ssh -ND 9999 root@YourIPAddress
...where YourIPAddress is replaced with whatever you wrote down above.
If this is the first time you're SSHing into your iPhone, it may take a bit for your secure key to be generating, so give it at least 30 seconds. You'll be asked if you're sure you want to continue connecting (answer "yes") and then you'll be prompted for a password. At the time of this writing, the default password for OpenSSH on your iPhone is alpine, though you should change the root password when you get a chance. After you've entered the correct password, the prompt will appear to hang. That's actually what should be happening, so you're on the right track.

Set Your Browser to Use SOCKS Proxy

At this point you just need to set your browser or operating system to use the SOCKS Proxy we've just set up to route our internet connection through the iPhone's EDGE connection. Gina's post shows how to do this with Firefox, though I'll admit I had some trouble getting the proxy to play properly with Firefox on my Mac. Your mileage may vary, but as an alternative I'll show you how to set it up in Safari, which worked well for me.
First, open the Safari Preferences, go to the Advanced tab, and click the Proxies "Change Settings" button. Make sure you're looking at your Airport advanced settings and are viewing the Proxies tab. Tick the SOCKS Proxy checkbox, enter localhost in the section labeled SOCKS Proxy Server and 9999 in the port next to it. Hit OK and Apply your settings. Then just head back to Safari and you're ready to browse.

Couldn't This Work Better?

I'll admit that my SSH/SOCKS chops are slim, so it's very likely this method could be built on to work even better than what I've set up above. That said, I can now browse from my laptop for free anywhere I've got my iPhone, so it could be worse. There are other methods available for tethering your iPhone, particularly this one, but I like the comparatively easy setup and cross-platform-ness of my setup. Alternatively, if you're feeling particularly adventurous/bored, you can boost your iPhone connection to 3G speeds by tethering the iPhone to a 3G mobile phone (which would be absurdly cumbersome). Tethering your iPhone to your laptop may be against AT&T's terms of service, so keep that in mind if you decide to go forward with this. If you've tried this or a similar method and have your own tips, let's hear them in the comments. Thanks to Lifehacker reader Vinod Panicker for the great idea.

from http://lifehacker.com/327066/use-your-iphones-internet-connection-on-your-laptop

No comments:

Post a Comment