0

Say I am doing something like this: (bsd variant of nc)

nc -k -l 8080 <fifo | nc 10.90.34.18 80 >fifo

This works great, I can use the server this is run on as a proxy to reach 10.90.34.18.

However, after performing a curl, it looks like the second nc command exits.

How can I prevent this?

  • What shell are you using? – camh Jul 15 '19 at 6:06
  • "This works great" Does it? How? What happens when the server on 10.90.34.18:80 closes the connection? – mosvy Jul 15 '19 at 6:11
  • Shell is bash. When the server closes the connection I believe this is what causes the second netcat process to exit. I suppose it would be more correct to say "This works great for a single connection". – cat pants Jul 15 '19 at 9:02
1

The answer is to use a while loop like so:

while true
do
  nc 10.90.34.18 80 >fifo
done < <(nc -k -l 8080 <fifo)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.