Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 17290  / 2 Years ago, sat, november 27, 2021, 9:54:04

I would like to use socat to redirect some ports and I found a socat daemon here. However this daemon lacks documentation and I could only setup for one port redirect. Is there any syntax to make socat or this daemon (or another daemon) to setup multiple individual ports redirecting?



Edit 1:
A possible solution found here.


More From » networking

 Answers
2

Run multiple instances in background



You could run multiple instances of socat in the background in one command.



I use sleep N instead of socat ...N... ...N... for an example:



echo -n 1 2 3 | xargs -d ' ' -I% bash -c '(sleep % ; echo slept % ) &'


The () and the echo slept % part is only needed to have some example output, so your actual command would be simpler; % will be replaced by one of the port listed after echo:



echo -n 3392 3393 3394 | xargs -d ' ' -I% bash -c 'socat TCP4-LISTEN:%,fork TCP4:192.168.10.102:% &'


Wit the count of port args N, this should also work:



parallel -j N -i bash -c 'socat TCP4-LISTEN:{},fork TCP4:192.168.10.102:{}' -- 3392 3393 3394

[#23273] Saturday, November 27, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
whipstder

Total Points: 189
Total Questions: 110
Total Answers: 99

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
;