Rinetd purpose is to redirects the TCP connections from one IP address and port to another. Since rinetd runs as a single process using nonblocking I/O, it is able to redirect a large number of connections without a severe impact on the machine. This article will shows how you can do port-forwarding with rinetd on Windows operating system such as windows xp, windows server 2008 server, windows server 2003 and etc. Please follow below steps:
1. Download rinetd
2. Configure rinetd.conf as per below
Please create rinetd.conf and put it in C:\rinetd folder, together with rinetd.exe
192.168.2.2 80 192.168.2.5 80
You will redirect ip 192.168.2.2 with port 80 to 192.168.2.5 with port80
C:\>cd rinetd C:\rinetd>dir Volume in drive C is OS Volume Serial Number is 9314-A45E Directory of C:\rinetd 03/15/2011 10:37 PM . 03/15/2011 10:37 PM .. 04/13/2003 01:29 PM 2,043 CHANGES 02/17/1999 06:34 PM 22,320 getopt.c 02/17/1999 06:15 PM 4,551 getopt.h 04/13/2003 01:28 PM 8,484 index.html 03/01/1999 10:41 AM 166 Makefile 03/01/1999 10:39 AM 3,612 match.c 08/07/1998 11:54 AM 188 match.h 04/13/2003 01:27 PM 770 README 03/15/2011 10:29 PM 97 rinetd-run.bat 03/01/1999 10:42 AM 6,936 rinetd.8 04/13/2003 01:26 PM 35,445 rinetd.c 03/15/2011 09:26 PM 29 rinetd.conf 02/17/1999 10:12 PM 3,555 rinetd.dsp 02/17/1999 06:00 PM 535 rinetd.dsw 04/13/2003 01:33 PM 290,893 rinetd.exe 03/15/2011 09:56 PM 1,975 rinetd.ini 02/17/1999 10:12 PM 74,752 rinetd.ncb 02/17/1999 10:12 PM 48,640 rinetd.opt 02/17/1999 06:49 PM 2,173 rinetd.plg 03/15/2011 09:06 PM 114,688 ServiceEx.exe 20 File(s) 621,852 bytes 2 Dir(s) 463,695,872 bytes free
3. Run rinetd (manually).
C:\rinetd>rinetd.exe -c rinetd.conf
We can also create a batch file, and call rinetd-run.bat to start rinetd with a click:
@echo off c: cd c:\rinetd\rinetd start c:\rinetd\rinetd.exe -c c:\rinetd\rinetd.conf Exit
4. Download ServiceEx, a windows application that allows a normal program to run as a Windows service.
5. Configure ServiceEx to make rinetd a windows service.
Refer and download http://serviceex.com/files/ServiceEx.ini.sample
Modify the changes on ServiceEx.ini.sample and save as rinetd.ini
; Instructions for installing a service: ; ; 1. Edit this file. You need to fill in the values for ServiceExeFullPath, options, ; desktop, Start and StartNow below. ; 2. Decide on a name for the service. ; 3. Save this file as that name, with an .ini extension added. For example, if you will name ; the service "NotepadService", you would save this file with the name NotepadService.ini ; in the same directory where ServiceEx.exe is located. ; 4. In Windows, select Start/Run then enter "cmd", without the quotes, in the prompt. ; 5. Chdir to the directory where you have placed ServiceEx.exe ; 6. Type "ServiceEx install ". If all goes well your service will be installed (and running, ; if you so specified). ; ; ; Once you have run ServiceEx successfully, if you want to change the values in this file, you should do the following: ; ; 1. Stop the service (i.e. run "net stop at the command line) ; 2. Remove the service (i.e. run "ServiceEx remove ) ; 3. Edit and save this file as desired. This file must be named the same as the service name with an .ini extension added. ; 4. Install the newly configured service (i.e. run "ServiceEx install ). ; ; Unless you change the executable file, it is better to use the service manager to modify these values. ; Please visit serviceex.com for information on how to do that. ; ; full path to exe to be run as a service--use quotes if path contains spaces ; The section identifier below is REQUIRED [ServiceEx] ServiceExeFullPath = "c:\rinetd\rinetd.exe" ; program arguments to be sent to executable options = -c c:\rinetd\rinetd.conf ; can program interact with desktop [true | false] (default: true) desktop = true ; start type (valid values: Auto Manual Disabled) (default: auto) Start=Auto ; start the service upon installation [true | false] (default: no) StartNow=false
If you open rinetd.ini, you will notice this changes
ServiceExeFullPath = "c:\rinetd\rinetd.exe" ; program arguments to be sent to executable options = -c c:\rinetd\rinetd.conf
6. Run rinetd as a windows service
ServiceEx install rinetd
You can start and stop it using command line utilities.
To start: "net start rinetd" To stop: "net stop rinetd"
If you browse http://192.168.2.2, it will show you http://192.168.2.5 website.
As always if you need any help you can reach us on twitter @ehowstuff or drop us a comment below. Jumping through archives page to read more articles..