5 ms·
socat is better for this. It plumbs any connection to any connection. Listen on port 8080 and route to some local 22? socat TCP-LISTEN:8080,fork,reuseaddr TCP
by AnotherGoodName 3y ago
socat is better for this. It plumbs any connection to any connection.
Listen on port 8080 and route to some local 22?
socat TCP-LISTEN:8080,fork,reuseaddr TCP:[somelocalip]:22
This lets you be very explicit in watching this run and killing when done.
Socat also lets you route networks through old serial ports, log all data going over a connection to a file, and even join completely different protocols.
Fun past projects based on socat; a serial port->socat to tcp out->socat on another computer to listen->a serial port out. Basically this created a serial port that worked over a satellite for a customer doing some remote monitoring so they could set an alarm if something failed (a lot of equipment only has serial connectivity for status).
- em-bee 3y agobut socat is a process that needs to run, so someone needs to configure it to start at boot. that's what the iptables solution avoids.
- AnotherGoodName 3y agoYeah the quick and dirty socat way can be an advantage or disadvantage. I like it for the times i just need to quickly get something through as a once off exactly because it runs when i run it. I feel like hacking some port mapping up during a disaster as more of a socat thing than an iptables thing but hey if it works it works.
- jasonjayr 3y agoSocat would make the connections to ssh show up from the machine running socat, rather than the origin, which might have auditing/logging implications. iptables with a dnat redirect addresses that.