Rinetd is a tool for redirecting Transmission Control Protocol (TCP) connections on a Unix and Linux operating system. Rinetd is a single-process server that handles any number of connections to address/port pairs specified in the configuration file /etc/rinetd.
It is easy to forward TCP and UDP ports from the firewall to internal hosts using iptables. But what if you need to forward traffic from a private address to a machine that isn't even on your current network? You can use rinetd;
download, if wget http://www.boutell.com/rinetd/http/rinetd.tar.gz can not download. Paste the address directly to the webpage to download http://www.boutell.com/rinetd/http/rinetd.tar.gz
Download and unzip the
tar -xvf rinetd.tar.gz
Enter the unzip directory make && make install; then execute echo $? See if there is an error;
add a configuration file
[root@jw rinetd]# vim /etc/rinetd.conf
[root@jw rinetd]# cat !$
cat /etc/rinetd.conf
0.0.0.0 6379 111.111.111.111 6379
##说明一下(0.0.0.0表示本机绑定所有可用地址)
###将所有发往本机6379端口的请求转发到111.111.111.111的6379端口,即redis
logfile /var/log/rinetd.log ——日志目录
[root@jw rinetd]#
Configuration file binding format The
command format is
bindaddress bindport connectaddress connectport
binding address binding port connecting address connecting port
[root@jw rinetd]# rinetd
[root@jw rinetd]# echo $?
0
[root@jw rinetd]# netstat -antup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 3096/rinetd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1025/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1092/sshd
tcp 0 52 192.168.3.2:22 192.168.3.100:1529 ESTABLISHED 1120/sshd
tcp 0 0 :::111 :::* LISTEN 1025/rpcbind
tcp 0 0 :::22 :::* LISTEN 1092/sshd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1025/rpcbind
udp 0 0 0.0.0.0:776 0.0.0.0:* 1025/rpcbind
udp 0 0 0.0.0.0:68 0.0.0.0:* 955/dhclient
udp 0 0 :::111 :::* 1025/rpcbind
udp 0 0 :::776 :::* 1025/rpcbind
[root@jw rinetd]#
Execute the rinetd command, you can see that port 6379 has been started.
Stop rinetd command
pkill rinetd
rinetd -c /etc/rinetd.conf ##Start forwarding
echo rinetd >>/etc/rc.local##Add to startup
If you bought a redis in Alibaba Cloud and need public network access, You can refer to
the following link using rinetd : https://help.aliyun.com/document_detail/43850.html