10 Port Forwarding

By:
Stephen Carville
Rev:
08/23/02

Port Forwarding is also possible using OpenSSH (Sec 17.2).

10.1 Using xinetd redirect function

The simpliest and, in my opinion, the preferred way to handle redirecting unencrypted connections is to use the redirect
capability built into xinetd.

If necessary, add services names to /etc/services. For example:
geofwd 50005/tcp # GeoTrac forwarded port

1. Add service file to /etc/xinetd.d. Example file:
# default: on
# description: forward connections to indian:1005
service geofwd
{
flags = REUSE
socket_type = stream
wait = no
user = root
redirect = 192.168.124.4 1005
log_on_failure += USERID
}

2. Restart xinetd
# /etc/rc.d/init.d/xinetd restart

10.2 Using Netcat

The netcat utility is sometimes described as the ‘Swiss Army Knife” of the network. Here we are using it for very basic
port forwarding from an externally accessible server to an internal server. If it is not necessary to run the forwarding
service continiously, on Redhat it is prefereable to use xinetd forwarding.

1. Install netcat from CDROM or from ftp
# rpm -Uvh ftp://volga/pub/RPMS/nc-*.rpm
2. Add services names to /etc/services. For example:
geofwd 50005/tcp # GeoTrac forwarded port(netcat)
3. Add service file to /etc/xinetd.d. Example file:
4. # default: on
# description: forward connections to panama:1005
service geofwd
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/bin/nc
server_args = 192.168.124.38 1005
log_on_failure += USERID
}

5. Restart xinetd
# /etc/rc.d/init.d/xinetd restart

Leave a Reply

You must be logged in to post a comment.