Tunneling over SSH

From braindump
Revision as of 18:32, 24 May 2012 by Uroesch (talk | contribs)
Jump to navigation Jump to search

Whacky tunnel stuff

Problem: Create a tunnel on a machine where an application is supposed to connect to a host that has been firewall-ed. Condition you can not restart the application to point to localhost in stead of the address at hand.

Solution:

Asuming my target we want to connect to is 1.2.3.4 on port 56789 we have to first make sure we have the sshd accept remote forwards on all interfaces and ip addresses.

In /etc/ssh/sshd_config file ensure that these two values are set to yes

AllowTcpForwarding yes
GatewayPorts yes

HUP the sshd process. And create a connection to the host in question.

 ssh source-host -R 56789:destination-host:56789 

On the source-host create an interface on the lo interface with this address;

ifconfig lo:1 1.2.3.4 netmask 255.255.255.255 broadcast 1.2.3.4 up

As soon as you bring the interface up you should see traffic going via the tunnel.