Forwarding a TCP Port using xinetd
Posted in Linux Corner on March 12th, 2010 by Friedrich Schäuffelhut – 2 CommentsEver needed to forward a TCP port from one host to an other? Then xinetd is your friend!
Forwarding a port from one machine to an other one is pretty simple. Create a new file in /etc/xinetd.d, e.g. /etc/xinetd.d/portfw:
service my-web { type = UNLISTED socket_type = stream protocol = tcp wait = no user = root bind = 0.0.0.0 port = 8888 only_from = 0.0.0.0 redirect = 192.168.1.1 80 }
The keyword service is followed by the service name. The service name must either be listed in /etc/services or may be set to an arbitrary name which requires type to be set to UNLISTED. The two entries bind and port define the ip address and port xinetd will bind and listen to. Any incoming connection will be redirected to the ip address and port defined via the redirect entry.
Often you’ll find the entry only_from = localhost in /etc/xinted.conf . This will inhibit connections to the newly created port from any source besides localhost. Sadly xinetd is not very verbose about why a connection is aborted. So it can take some time to find the actual reason for a non working port forward. Using a only_from entry directly in the service configuration will overwrite the system wide default. A value of 0.0.0.0 means connections from any source are accepted.
May 21st, 2012 18:48
[...] solved using XINETD: http://www.schaeuffelhut.de/wordpress/?p=6 Thank you [...]
August 30th, 2013 09:53
Good Article , I’ll use it instead redir!