<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kb.rvmgroup.it/index.php?action=history&amp;feed=atom&amp;title=Creare_un_proxy_SOCKS_con_ssh</id>
	<title>Creare un proxy SOCKS con ssh - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://kb.rvmgroup.it/index.php?action=history&amp;feed=atom&amp;title=Creare_un_proxy_SOCKS_con_ssh"/>
	<link rel="alternate" type="text/html" href="https://kb.rvmgroup.it/index.php?title=Creare_un_proxy_SOCKS_con_ssh&amp;action=history"/>
	<updated>2026-05-06T15:55:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://kb.rvmgroup.it/index.php?title=Creare_un_proxy_SOCKS_con_ssh&amp;diff=5116&amp;oldid=prev</id>
		<title>Gabriele.vivinetto at 13:29, 3 March 2007</title>
		<link rel="alternate" type="text/html" href="https://kb.rvmgroup.it/index.php?title=Creare_un_proxy_SOCKS_con_ssh&amp;diff=5116&amp;oldid=prev"/>
		<updated>2007-03-03T13:29:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Se si è in una Lan dove è consentito uscire in ssh, ma non con altre porte TCP, è possibile creare un proxy SOCKS 5 da usare per &amp;quot;intubare&amp;quot; le altre connessioni.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;ATTENZIONE&amp;#039;&amp;#039;&amp;#039;: il proxy socks 5 di SSH non supporta traffico UDP, quindi applicazioni tipo VPN su porte UDP non funzionano ([http://www.employees.org/~satch/ssh/faq/ssh-faq-5.html#ss5.5 5.5. Can I use ssh to securely forward UDP-based services, such as NFS or NIS?]); vedi oltre per un workaround.&lt;br /&gt;
&lt;br /&gt;
Per attivare il proxy collegarsi al proprio host con il comando:&lt;br /&gt;
&lt;br /&gt;
 ssh -D 1080 mio.server.dom&lt;br /&gt;
&lt;br /&gt;
A questo punto sarà attivo un proxy SOCKS5 TCP su localhost sulla porta 1080.&lt;br /&gt;
&lt;br /&gt;
Configurare ad esempio in FF come proxy socks 5 localhost sulla porta 1080 e collegarso ad assitenza.rvmgroup.it: l&amp;#039;ip rilevato sarà mio.server.dom.&lt;br /&gt;
NATURALMENTE su mio.server.dom deve essere permesso il forwarding del servizio che si intuba.&lt;br /&gt;
&lt;br /&gt;
==Proxy SOCKS in Ubuntu==&lt;br /&gt;
&lt;br /&gt;
Gnome permette di configurare un proxy per il proprio ambiente, provare prima ad impostarlo in&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;Sistema / Preferenze / Proxy di rete&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Chiudere e riavviare le applicazioni. Dovrebbero automaticamente usare questa impostazione.&lt;br /&gt;
 &lt;br /&gt;
==Socksifizzazione di un&amp;#039;applicazione==&lt;br /&gt;
&lt;br /&gt;
Se l&amp;#039;applicazione che si vuole usare non supporta socks si può installare &amp;#039;&amp;#039;&amp;#039;tsocks&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install tsocks&lt;br /&gt;
&lt;br /&gt;
La configurazione base può essere:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat | sudo tee /etc/tsocks &amp;gt;/dev/null &amp;lt;&amp;lt;EOFile&lt;br /&gt;
server = 127.0.0.1&lt;br /&gt;
# Server type defaults to 4 so we need to specify it as 5 for this one&lt;br /&gt;
server_type = 5&lt;br /&gt;
# The port defaults to 1080 but I&amp;#039;ve stated it here for clarity &lt;br /&gt;
EOFile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ora si può lanciare l&amp;#039;applicazione con&lt;br /&gt;
&lt;br /&gt;
 tsocks applicazione&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Oppure per tutte i comandi da terminale, attivare tsocks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tsocks on&lt;br /&gt;
comandi&lt;br /&gt;
...&lt;br /&gt;
tsocks off&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Performing UDP tunneling through an SSH connection==&lt;br /&gt;
&lt;br /&gt;
Vedi [http://zarb.org/~gc/html/udp-in-ssh-tunneling.html Performing UDP tunneling through an SSH connection]&lt;br /&gt;
&lt;br /&gt;
The Swiss ISP [http://www.bluewin.ch/ Bluewin] sucks. Their DNS are often down. A friend even received advice from Bluewin technicians to not use their own DNS!... But then, it is quite hard to gain access to another DNS for free, if you don&amp;#039;t have access to a co hosted machine. In this document, we&amp;#039;ll access another machine&amp;#039;s network internal DNS services (UDP port 53) with only SSH access to it. We will forward UDP/53 traffic to TCP, then TCP traffic with the port-forwarding mechanism of SSH, then TCP to UDP/53 on the other end. Typically, you can do it with [http://openvpn.net/ openvpn]. But here, we&amp;#039;ll do it with simpler tools, only [http://www.openssh.com/ openssh] and [http://m.nu/program/util/netcat/netcat.html nc].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Open a TCP forward port with your SSH connection===&lt;br /&gt;
&lt;br /&gt;
On your local machine (&amp;lt;tt&amp;gt;local&amp;lt;/tt&amp;gt;), connect to the distant machine (&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;) by SSH, with the additional &amp;lt;tt&amp;gt;-L&amp;lt;/tt&amp;gt; option so that SSH will TCP port-forward:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
     local# ssh -L 6667:localhost:6667 server.foo.com&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This will allow TCP connections on the port number &amp;lt;tt&amp;gt;6667&amp;lt;/tt&amp;gt; of your local machine to be forwarded to the port number &amp;lt;tt&amp;gt;6667&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;server.foo.com&amp;lt;/tt&amp;gt; through the secure channel.&lt;br /&gt;
&lt;br /&gt;
===Setup the TCP to UDP forward on the server===&lt;br /&gt;
&lt;br /&gt;
On the server, we open a listener on the TCP port 6667 which will forward data to UDP port 53 of a specified IP. If you want to do DNS forwarding like me, you can take the first nameserver&amp;#039;s IP you will find in &amp;lt;tt&amp;gt;/etc/resolv.conf&amp;lt;/tt&amp;gt;. But first, we need to create a fifo. The fifo is necessary to have two-way communications between the two channels. A simple shell pipe would only communicate left process&amp;#039; standard output to right process&amp;#039; standard input.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
     server# mkfifo /tmp/fifo&lt;br /&gt;
     server# nc -l -p 6667 &amp;lt; /tmp/fifo | nc -u 192.168.1.1 53 &amp;gt; /tmp/fifo&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This will allow TCP traffic on server&amp;#039;s port 6667 to be forwarded to UDP traffic on 192.168.1.1&amp;#039;s port 53, and responses to come back.&lt;br /&gt;
&lt;br /&gt;
===Setup the UDP to TCP forward on your machine===&lt;br /&gt;
&lt;br /&gt;
Now, we need to do the opposite of what was done upper on the local machine. You need priviledged access to bind the UDP port 53.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
     local# mkfifo /tmp/fifo&lt;br /&gt;
     local# sudo nc -l -u -p 53 &amp;lt; /tmp/fifo | nc localhost 6667 &amp;gt; /tmp/fifo&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This will allow UDP traffic on local machine&amp;#039;s port 53 to be forwarded to TCP traffic on local machine&amp;#039;s port 6667.&lt;br /&gt;
&lt;br /&gt;
===Enjoy your local DNS server :)===&lt;br /&gt;
&lt;br /&gt;
As you&amp;#039;ve probably guessed it now, when a DNS query will be performed on the local machine, e.g. on local UDP port 53, it will be forwarded to local TCP port 6667, then to server&amp;#039;s TCP port 6667, then to server&amp;#039;s DNS server, UDP port 53 of 192.168.1.1. To enjoy DNS services on your local machine, put the following line as first nameserver in your &amp;lt;tt&amp;gt;/etc/resolv.conf&amp;lt;/tt&amp;gt;&amp;lt;nowiki&amp;gt;: &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
     nameserver 127.0.0.1&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Riferimenti==&lt;br /&gt;
&lt;br /&gt;
*[http://muffinresearch.co.uk/archives/2007/01/19/ssh-socks-proxy/ SSH SOCKS Proxy | Muffin Research Labs by Stuart Colville]&lt;br /&gt;
*[http://marc.abramowitz.info/archives/2006/01/28/tsocks/ Marc Abramowitz » tsocks]&lt;br /&gt;
*[http://marc.abramowitz.info/archives/2006/02/18/evolution-using-a-socks-proxy/ Marc Abramowitz » Evolution: Using a SOCKS proxy]&lt;br /&gt;
*[http://en.opensuse.org/OpenSSH#SOCKS OpenSSH - openSUSE]&lt;/div&gt;</summary>
		<author><name>Gabriele.vivinetto</name></author>
	</entry>
</feed>