Skip to content

By Administrator in All, Linux administration

When it comes to redirecting TCP traffic, rinetd is a pretty old-school, frequently overlooked, simple and very efficient way to go. rinetd is an application layer port forwarder which, unfortunately, only supports the TCP protocol and not UDP. It is somehow similar to the once popular super-server daemons such as inetd, xinetd and rlinetd but it is simpler and best suited for redirecting TCP connections.

The settings of the rinetd daemon are by default stored in the /etc/rinetd.conf file and they follow a pretty intuitive syntax:

# bindaddress    bindport  connectaddress  connectport          22           2222

The above configuration line would obviously forward all TCP traffic destined for port 22 on the local IP address to port 2222 on the remote IP address. If you use as the bindaddress, this would redirect connections headed to any local IP address.

rinetd is also capable of logging redirected connections. The log file is specified in the configuration file with the following option:

# logging information
logfile /var/log/rinetd.log

For the sake of testing, I placed the following line in the /etc/rinetd.conf configuration file: 25 25

Then, I restarted the service and tried to establish a connection to my local port 25:

[email protected]:~$ sudo /etc/init.d/rinetd restart
Stopping internet redirection server: rinetd.
Starting internet redirection server: rinetd.
[email protected]:~$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 ESMTP t7sm47101974eel.14
telnet> quit
Connection closed.
[email protected]:~$ tail /var/log/rinetd.log
05/Nov/2012:12:23:40  25   25
0  44   done-remote-closed

As can be seen, my connection was redirected to Google’s SMTP server and the redirection was logged into the rinetd log file.

Tags: , , ,

Comment Feed

No Responses (yet)

Some HTML is OK

or, reply to this post via trackback.