60 votes

Forward local port or socket file to remote socket file

Altough in the time, when the question was asked, it was really impossible, but it is possible nowadays. You can to both: UNIX => TCP and UNIX => UNIX forwarding. For example (LOCAL PORT TO ...
Igor Chubin's user avatar
10 votes
Accepted

How to set up a persistent TCP gender-changer proxy?

The important question is, how will A react to loss of connection, or to connection being refused? Anything that just assumes that a single TCP connection will stay up forever is going to be fragile; ...
telcoM's user avatar
  • 4,598
9 votes

Forward local port or socket file to remote socket file

No more socat is needed since ssh 6.7. You can forward unix domain sockets directly like: ssh -nNT -L $(pwd)/docker.sock:/var/run/docker.sock user@someremote More info: https://medium.com/@dperny/...
CMCDragonkai's user avatar
7 votes
Accepted

socat forwarding to multiple addresses

Based on my earlier comments, I have just tested this solution[1] and it works as expected, if I understood your needs: socat -u tcp4-listen:1934 - | tee >(socat - tcp4:127.0.0.1:1935) >(socat -...
Patrick Mevzek's user avatar
7 votes
Accepted

Always keep socat alive

If you're using a LISTEN command like OPENSSL-LISTEN, TCP-LISTEN, etc., the fork option will spin off connections to a child process so that socat can continue receiving. Example: socat - OPENSSL-...
jtpereyda's user avatar
  • 188
5 votes
Accepted

socat CREATE returning Bad file descriptor

At this point in time, socat apparently assumes bi-directional communication even when it doesn't make sense. To override this, use the -u (unidirectional) switch. e.g. socat -u UDP-RECVFROM:9999 ...
tudor -Reinstate Monica-'s user avatar
4 votes
Accepted

Socat - is it possible?

Like this? socat tcp-listen:8080,reuseaddr,fork system:'ls; exec socat - tcp\:localhost\:80' 1st parameter gets ,fork to have socat stay listening for more connections system: is preferred over exec:...
A.B's user avatar
  • 12.7k
3 votes
Accepted

How to capture UDP traffic so it can be piped to grep

socat -u UDP-RECVFROM:8125,fork SYSTEM:"sed G" This seems to work although there is a bit more than just new line attached. Also maybe this thread can help: https://unix.stackexchange.com/questions/...
Radi Radichev's user avatar
3 votes

socat tun device very low throughput

I was having a similar issue when using socat to create an IP connection between two computers using a Bluetooth serial connection (via rfcomm). The raw serial connection was rather fast (15 or so KiB/...
i3Craig's user avatar
  • 31
3 votes

How to set up a persistent TCP gender-changer proxy?

The real world is messy. In the real world sometimes TCP connections die, this may happen for example if a stateful firewall or NAT is rebooted, if the connection goes too long without traffic, if ...
Peter Green's user avatar
  • 4,296
3 votes

echo server with netcat or socat

netcat solution pre-installed in Ubunutu The netcat pre-installed in Ubuntu 16.04 comes from netcat-openbsd, and has no -c option, but the manual gives a solution: sudo mknod -m 777 fifo p cat fifo |...
Ciro Santilli OurBigBook.com's user avatar
2 votes

IPv4 to IPv6 proxy/passthrough

You can set up a https://tunnelbroker.net/ tunnel to add IPv6 to your home system. Also some ISPs have IPv6 configurations that would allow native connectivity.
Jason Martin's user avatar
  • 5,093
2 votes

UDP multicast send/receive: Routing or socat issues?

It turns out it is a routing problem on the switch. Multicast routing for the VLAN in 10.1.1.x is not turned on. Once we added 'pim sparse-mode' on our cisco router. Everything is working as ...
surfcode's user avatar
  • 245
2 votes

Forward local port or socket file to remote socket file

Another modification of @mpontes'/@javier's answer that ssh user@remoteserver -L 9999:localhost:9999 'socat TCP-LISTEN:9999,fork,bind=localhost UNIX-CONNECT:/var/run/mysqld/mysql.sock& pid=$!; ...
Andy's user avatar
  • 128
2 votes
Accepted

how to create a tar file with checksums, but without compression

You can use lz4 as a drop-in replacement for gzip. The compression rate is not as good, but it is usually blazing-fast compared to gzip. It may still be too slow for what you're trying to do, but it ...
Andreas Rogge's user avatar
1 vote

Using socat forwarder over HTTP tunnel (CONNECT) over SSL/TLS

It would be a 'heavy' workaround - but you can always use stunnel to encapsulate your connection inside TLS. Here's an example on how to use it: sudo apt install stunnel4 # /etc/stunnel/service.conf [...
NiceRath's user avatar
1 vote
Accepted

What is the iptables equivalent to what socat does?

Something like the following: iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination some-random-host-in-another-network.com:80 iptables -t nat -A POSTROUTING -d some-random-host-...
Nikita Kipriyanov's user avatar
1 vote
Accepted

Invoke remote program with socat and wait for it to complete

OK, I think I have it: put -t 10 on both client and server, and they'll both wait 10 seconds after EOF from the client before closing both sockets. Protip: use lots of -d to get a view into what ...
koehn's user avatar
  • 321
1 vote

How to tunnel the serial port from a remote machine?

This will work seamlessly but only with a raw server (on the Opengear) and not with a telnet one: $ socat -d TCP:server:port PTY,link=$HOME/dev/vmodem0,rawer,b115200,sane $ screen ~/dev/vmodem0 That'...
crististm's user avatar
  • 141
1 vote

Can socat be used to forward an ssh-agent socket into a chroot?

You can forward the SSH Agent into a chroot but you have to jump through a few hoops, the first of which is making the socket accessible in the chroot and the second is telling users within chroot ...

Only top scored, non community-wiki answers of a minimum length are eligible