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 ...
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; ...
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/...
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 -...
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-...
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 ...
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:...
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/...
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/...
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 ...
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 |...
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.
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 ...
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=$!; ...
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 ...
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
[...
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-...
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 ...
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'...
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 ...
Community wiki
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
socat × 65linux × 14
tcp × 10
netcat × 9
port-forwarding × 8
proxy × 6
udp × 6
networking × 5
iptables × 5
serial × 5
linux-networking × 4
haproxy × 4
port × 4
socket × 4
redirection × 4
ubuntu × 2
ssh × 2
bash × 2
redirect × 2
tunneling × 2
tunnel × 2
ip-forwarding × 2
iperf × 2
multiplexing × 2
apache-2.2 × 1