wsh25
wsh25

Reputation: 55

Any alternatives to socat and netcat for port forwarding?

I need to forward an exposed port of a Docker container to a remote port of a remote server. There are two approaches. One is with IP tables, but this wouldn't work for me since I'm not able to give NET_ADMIN access to my containers, which will be running on a cloud provider's Kubernete hosting platform. The second approach would be to utilize SOCAT, but that has it's own problems since it forks a process for each connection, reaching the maximum allowed open files in no time since I have thousands of concurrent connections.

Are there any alternatives, which can forward a port like iptables does, but without NET_ADMIN requirements, and without needing to create a process for each connection?

Upvotes: 0

Views: 3250

Answers (1)

Veera Nagireddy
Veera Nagireddy

Reputation: 1890

Check below options :

1)If you want to connect to a port on a specific IP address without the use of netcat.

Try this telnet host.example.com port (e. g. telnet www.example.com 80).

Another possibility is /dev/tcp:

$ echo "HEAD / HTTP/1.0" >/dev/tcp/[www.example.com/80][1].

2)There's a tiny, light resources program called redir which is pretty configurable.

apt-get install redir to install on Debian-based distributions.

redir :SRC :DEST will run in the background as a daemon.

3)Rinetd, It's a daemon that redirects TCP connections. Have a look at the man page to see if it suits your needs: https://manpages.debian.org/unstable/rinetd/rinetd.8.en.html

4)portfwd, (TCP and UDP forwarding) https://portfwd.sourceforge.net/, (it latest release is 2007, and it works on 2.6 kernel).

Upvotes: 2

Related Questions