I've successfully used netcat as a proxy, such as a web proxy by
running the following:
nc -l -p 80 0<backpipe | tee -a inflow | nc 10.1.5.121 81 | tee -a
outflow 1>backpipe
where 10.1.5.121 was the web server itself (listening on port 81).
That's no problem to set up. However, what I really need to do is a
bit different (almost like a chat server, perhaps). I would like to
have netcat listen on say, ports 1111 AND 2222:
nc -l -p 1111
nc -l -p 2222
Also, no problem, but what I need to do next is connect the two
together. This is where I'm stumped. I've tried all kinds of ways to
do this. If I do something similar to the following, it does work, but
I also get a local echo on each of the client connections, which I
think is what's killing it:
nc -l -vv -p 1111 0<backpipe | tee -a inflow | tee -a outflow
1>backpipe &
nc -l -vv -p 2222 0<backpipe | tee -a inflow | tee -a outflow
1>backpipe &
I have two devices that need to connect to different ports on this
proxy and then have their streams connected together so that they can
talk. Basically, they are both behind firewalls and I cannot gain
inbound access to either one, so they must both connect to this proxy
in order to communicate. Any ideas out there?
Thanks!
Matt.
|