Sunday, October 5, 2008

How to share iphone's internet connection with you laptop using Wi-Fi connection, or say use iphone as a modem

This article aims to provide a way to connect your laptop with iphone using Wi-Fi connection, and use iPhone as the modem of your laptop, so you can have access to the internet with your iphone's 3G or 2G data service. This is really cool when you are at home and have a laptop, but you don't have internet access, either wired or wireless. The bandwidth is good, with this trick, you firefox is enabled to surf on the Internet.

Step 1: Jailbreak your iphone. (How to? I will write another article on how to do this. )
Before you do this, think carefully, because it violates the warrenty.

Step 2: Create a Ad-Hoc (device-to-device) connection using your laptop, in order to achieve this task, refer to my article for windows xp here, for mac os, I think it is also very easy.
Add your iphone to this network (Settings->Wi-Fi->enable Wi-Fi and choose the ad-hoc network)

Step 3: Install 3Proxy and Terminal

After jail broke iPhone, a Cydia icon will appear on one of the App pages. Load Cydia, and after self updating by Cydia, go to Install tab -> All Packages. Install both MobileTerminal and 3Proxy, then hit the Home button. The phone will restart and Terminal will be installed on iPHone Home screen. (refer to this page)
MobileTerminal enables you to run program with terminal as in linux.
3Proxy is for making your iphone a server using socks 5 protocol.

Step 4: Find your iPhone's IP address. 
This can be found by running "ifconfig" command in the terminal, but of course, you need to first install the package required for "ifconfig", search it in Cydia
Or, the easier way is the go inside the Wi-Fi connection by clicking the ">" sign of the current Wi-Fi connection in the "Settings->Wi-Fi" menu, write this address down in a paper.

Step 5: Open the terminal, type "socks" and click "return", it will hang there, it is fine, because the server is running and waiting for connection

Step 6:Run Safari on the iPhone and Open a Web Page
Launch Mobile Safari on iPhone and browse to any web page.
Note that this step is important to ensure that iPhone will internally switch itself and fallback to 3G GSM data connection when it fails to get through to Internet using the ad-hoc wireless connection, without dropping or terminating the ad-hoc network, allowing the SOCKS proxy server to transmit and transfer data via 3G network connection
(Each time when you find the iphone modem is not working, you should repeat this step)

Step 7: Configure Web Browser Fire Fox
Run Firefox web browser to configure proxy server for Internet traffic. In Firefox, go to Preferences -> Advanced -> Network -> Settings. Then, fill in the iPhone’s IP address written down from step 5 above into the SOCKS Host field, and enter 1080 as the port number.
Make sure all other proxy fields are blank and/or 0.

Step 8: Tunnel and Forward DNS Resolution Requests Through SOCKS Proxy
3Proxy SOCKS proxy can resolve target DNS names if the application sends domain name resolving requests to the SOCKS proxy. However, each application that requires to go to Internet via SOCKS proxy had to be configured manually, as most program will attempt to resolve a domain name against remote DNS server via HTTP protocol.

Firefox, for one, has such capability to force DNS resolution via SOCKS protocol. To enable such advanced option, type "about:config" into Firefox URL Location Bar. A huge list will appear, search for "socks" and change the value for network.proxy.socks_remote_dns preference to true (double click to change the value).
The DNS resolution limitation through SOCKS proxy also explains why some applications do not successfully browsing or connecting to Internet websites through tethering iPhone. However, once DNS requests have been cached locally, the domain will work system wide.

Now you can use the configured Fire Fox to go to any websites you are interested. You can do everything, even watch youtube videos smoothly.

(Don't forget to restore the changes that you made just now)
Step 9: Terminate socks proxy
After using the Internet connection via iPhone, terminate the SOCKS proxy server running on iPhone by switching back to Terminal, and then press and hold the Home button until Terminal quits, else it may slowly drain the battery life of iPhone.

Step 10: Change the fire fox configuration back, think what you did just now, and reverse.

Have fun!

4 comments:

Anonymous said...

Great blog you got here. It would be great to read more about this topic. The only thing I would like to see on that blog is a few pics of some gadgets.
Katherine Flouee
Block phone

Brad Fallon said...

How can I browse the Internet on my old Nokia phone (with no service) using my computer's Internet access?

Anonymous said...

How can i get my iphone internet to work after updating to iphone 4?

Herman Miller chair said...

Can an iphone 4 use itself as a modem with the additions iphone modem 4 app?