How to Install and Configure Port Forwarding Using Rinetd in Windows

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.

See also  How to Setup WordPress Blog on CentOS 6.3

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.

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

Leave a Reply

Your email address will not be published. Required fields are marked *