Say you're running a virtual machine on your work computer. Say this machine, for whatever reason, can only connect to the internet over NAT - as in, it does not get it's own IP address. Say this VM is running a webserver, and you need a device outside of your computer to connect to it.
If only there was a way to get your work computer to 'share' it's network, so that you could get at that VM… Here's how you do it!
For all instructions, I assume your work computer is a mac
-
Get your computer's IP address:
ifconfig
-
Create a SOCKS proxy into your computer that allows for external traffic. First open up a terminal window, then run this command (replacing X's with your ip address or domain, and username with the user you usually SSH into your computer with):
ssh -N -gv -D 1080 [email protected]
If you do this correctly, you'll be asked to authenticate/login. Once logged in, you'll see a slew of text, at the end of which you'll see something like:
debug1: Local connections to *:1080 forwarded to remote address socks:0 debug1: Local forwarding listening on 0.0.0.0 port 1080.
You now have a SOCKS proxy set up that can accept external traffic. Leave this running.
-
Fire up your text editor, because we need to create a PAC (Proxy-auto-config) file so that the iPad can use this SOCKS proxy.
-
Create a file with an extension of
.pac
(i.e. myProxy.pac) -
Paste the following into it, replacing X's with your work computer's IP, and Y's with the port you used for the SOCKS proxy (1080 in this example):
function FindProxyForURL(url, host) { return "SOCKS XXX.XXX.XXX.XXX:YYYY"; }
-
Save this file, and make it accessible to the iPad. An easy way to do this is to throw it up on dropbox, or other cloud storage your iPad has access to.
On the iPad
- Open up settings > wifi.
- Click on the blue arrow next to your wifi connection.
- Scroll to the bottom where there is a section for HTTP Proxy.
- Select Auto from this section.
- In the URL field, key in the URL of the *.pac file you created and made web-accessible.
Voila, your iOS device should now have the network characteristics of your work computer, and all traffic from the iOS device should go through it. You can verify this by watching the SOCKS proxy running in your terminal. When you try to access a website on the iPad, you should see a connection being made in the SOCKS proxy terminal window.