PDA

View Full Version : SSH tunneling does not work on MAC OSX




PenguinApple
Sep 9, 2011, 03:07 AM
For connecting to the internal network in my office while working at home I use an SSH tunnel.

I found a script which sets it automatically :

#!/bin/bash
# http://richardkmiller.com/925/script-to-enabledisable-socks-proxy-on-mac-os-x

disable_proxy()
{
networksetup -setsocksfirewallproxystate Wi-Fi off
networksetup -setsocksfirewallproxystate Ethernet off
echo "SOCKS proxy disabled."
}

# triggered on abortion (e.g. Ctrl+C)
trap disable_proxy INT

#networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 3310
networksetup -setsocksfirewallproxy Ethernet 127.0.0.1 3310
networksetup -setsocksfirewallproxystate Wi-Fi on
networksetup -setsocksfirewallproxystate Ethernet on
echo "SOCKS proxy enabled."
echo "Tunneling..."
ssh -g -ND 3310 USER@MYOFFICEcom


This starts normally and the SOCKS proxy is checked in the Wifi (Airport) proxy settings in the system setting. And in Safari it works with whatsmyip,com which displays now my office's IP address rather than my home one.
My office uses 192.168.1.xxx subnet and at hoem I use 192.168.0.xxx, so I can access local websites within my office via Safari.

But now the catch:

When I use an entry
192.168.1.123 myentry.local
in the /etc/hosts file on my Mac

I CAN access the office site by 192.168,1,123 but I can NOT access the site by "myentry.local".

Moreover what works over SSH tunnel works ONLY in Safari. Firefox does not use this proxy setting and using ssh (from terminal or another ssh client) to an office server starting with 192.168.1 does not work either.

It seems that these settings are only valid for Safari.
What can be the problem here ?

Thanks.



Hansr
Sep 9, 2011, 03:13 AM
Firefox does not use the system proxy settings it uses it's internal proxy settings.

Try adding the .local to the hosts file on the machine you are ssh-ing into

PenguinApple
Sep 9, 2011, 05:13 AM
No this is not a Firefox problem.

I tried a third server as a proxy which is actually an Android phone (rooted Galaxy S2) which is in the same Wifi network as my Mac.

On the Galaxy I started the SSH tunnel app to my office and then it works perfectly with the 'myentry.local' in the 'hosts' of my Galaxy even when using Firefox on the Galaxy.
And then when I use my Galaxy as proxy server (which has an SSH tunnel running to my office) so I fill in the IP of my Galaxy as proxy server address on my Mac, the internal IP of my office works but the myentry.local does not.

Weird.