rinetd implements port mapping/forwarding/redirection

rinetd, implement port mapping/forwarding/redirecting
the official website address http://www.boutell.com/rinetd

Software download
wget http://www.boutell.com/rinetd/http/rinetd.tar.gz

Unzip and install
tar zxvf rinetd.tar.gz
make
make install

Edit configuration
vi /etc/rinetd.conf
0.0.0.0 8080 172.19.94.3 8080
0.0.0.0 2222 192.168.0.103 3389
1.2.3.4 80 192.168.0.10 80

Explain (0.0.0.0 means that the machine is bound to all available addresses)
forward all requests to port 8080 of this machine to port 8080 of 172.19.94.3 and forward
all requests to port 2222 of this machine to 3389 of 192.168.0.103 port
forwards all port 80 requests destined for 1.2.3.4 to port 80 on 192.168.0.10

The command format is
bindaddress bindport connectaddress connectport
bind address bind port connect address connect port
or
[Source Address] [Source Port] [Destination Address] [Destination Port]
source address source port destination address destination port

Start the program
pkill rinetd ##Close the process
rinetd -c /etc/rinetd.conf ##Start forwarding
Add this command to /etc/rc.local to automatically run at boot

View status
netstat -antup

It should be noted that
1. The local port bound in rinetd.conf must not be occupied by other programs
. 2. The system firewall running rinetd should open the bound local port.
For example:
-A RH-Firewall-1-INPUT -m state - -state NEW -m tcp -p tcp --dport 1111 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2222 -j ACCEPT

 

Reprinted from http://www.linuxidc.com/Linux/2011-01/31287.htm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326252835&siteId=291194637