How do I connect to a SOCKS Proxy from an iPhone/iPod Touch?
Well I guess, there's no better way to do it. Darn you Apple, is it so hard to put a SOCKS Proxy setting in the iPhone OS network settings panel? :-(
Anyway, the best answer so far, and the only one I could find on the Net, is from a document from the SNIPPLR Code 2.0 website entitled How To Connect To A SOCKS Proxy From An Unjailbroken iPhone/iPod Touch.
Below is a cleaned up version of their solution:
Let's say, perhaps, that you are already forwarding your web traffic through an SSH/SOCKS tunnel at work (for privacy reasons) and you would like to use that same tunnel on your iPhone/iPod Touch. This is actually pretty easy to accomplish.
-
Make sure the SOCKS tunnel on your work computer allows LAN connections so your iPhone/iPod Touch can connect to it.
ssh -N -g -D 1080 [email protected]
-
Create a text file and insert the following code:
function FindProxyForURL(url, host) { return "SOCKS 192.168.xx.xx:yyyy"; }
Replace the x's with your IP and the y's with the port you used after the -D in your SSH command
-
Save the text file as a Proxy Auto-Config (PAC) file to a web accessible place with a .pac extension.
If you're reading this chances are you know how to serve a file over HTTP on your work LAN, so I won't delve into that.
Finally, on your iPhone/iPod Touch, go to Settings → Wi-Fi and click the blue arrow to the right of your work network. Scroll to the bottom, click Auto and type in the address to your PAC file (e.g. http://192.168.xx.xx/mysupersecretproxy.pac).
Now you can surf the web securely from your iPhone/iPod touch.
Wow thanks for that last answer.
Together with this "SSH to get your iPhone online via USB cable" blog post, I came up with a pretty solid instant reverse SSH/SOCKS solution over USB tether given only an SSH server somewhere on your network. This allows all my tcp-based apps to use an SSH server's internet across USB despite my WiFi being defective and not having a strong phone data plan (T-Mobile Prepaid).
No proxy server configuration required.
The gist of the blog post is that you CAN control the proxy from the command line. Use the file:
/private/var/preferences/SystemConfiguration/preferences.plist
Find the "ip1" section (if you want to replace GPRS/EDGE/3G interface) like:
<dict>
<key>Interface</key>
<dict>
<key>DeviceName</key>
<string>ip1</string>
<key>Hardware</key>
<string>com.apple.CommCenter</string>
<key>Type</key>
<string>com.apple.CommCenter</string>
</dict>
Be careful that you got the ip1 section if you want to override EDGE/3G! Do not look for the other Proxies entries in the file.
Then add the following section afterwards:
<key>Proxies</key>
<dict>
<key>ProxyAutoConfigEnable</key>
<integer>1</integer>
<key>ProxyAutoConfigURLString</key>
<string>file:///private/var/preferences/proxy.pac</string>
</dict>
Then use your trick to specify an SOCKS proxy in the file we just specified:
/private/var/preferences/proxy.pac
Add:
function FindProxyForURL(url, host)
{
return "SOCKS 127.0.0.1:1080";
}
Change permissions on proxy.pac to 777 (all can read, write, execute).
Reboot the iPhone.
Download iTunnel for iTunes 9 (older versions are available too). (http://www.mediafire.com/?2q1fzowoy12)
Create a new Putty Connection: in Connection>SSH>Tunnels section add new forwarded "remote" port, like port 202 on the iPhone to your internet-facing SSH server (say, 192.168.2.100:22).
Source Port: 202
Destination: 192.168.2.100:22
In the SSH section of the same Putty Connection set your Remote Commmand to:
ssh -D 1080 [email protected] -p 202
Save your Putty configuration to a new named session.
Optionally generate keys & add the public keys to *~/.ssh/authorized_keys* to both ends so you don't need to type passwords. Use putty.exe -load "Profile Name" in a shortcut to speed it up even more.