Sometimes it is useful to route traffic through a different machine for testing or development. At work, we have a VPN to a remote facility that we haven't bothered to fix for routing, so the only way to access a certain machine over that VPN is via an SSH tunnel to a machine that is reachable over the VPN. Other times, I have used this technique to test internet-facing requests against sites I am developing. It is pretty easy, and if you don't use firefox regularly, you can treat Firefox as your "Proxy" browser and other browsers can use a normal configuration (Although you can also configure an entire system to use the proxy, other articles exists that discuss this potential).
- Open a terminal
ssh -ND 9999 username@your-remote-server.com
ssh
-N
- Do not execute remote commands, just open the connection for forwardingD 9999
- Create a local "dynamic" forwarding port on your local machine, and route all traffic through it to the remote machine via SOCKS v4 or v5
- Leave the terminal open, go to Firefox
- Open firefox settings, search for "SOCKS" and open the Network Proxy settings button that is now highlighted
- Select "Manual proxy configuration"
- Enter
localhost
for the SOCKS host, 9999 for the port, and SOCKS v5 selected. Click "OK" to save it.
- Leave the HTTP Proxy, SSL Proxy, and FTP proxy fields blank, with port 0 for each
- If you know what to fiddle with here, consider adjusting the "No proxy for" and "Proxy DNS when using SOCKS v5", if needed
You are now routing all Firefox traffic through your remote box. To verify, Google "What is myIP address" and compare the results in Firefox with those in another browser.
Note that you must change Firefox back to "No Proxy" to disable this effect. If you do not, and you close your SSH tunnel, Firefox will be 100% inoperable until a new tunnel is opened or you revert your network proxy settings in Firefox.