首页 » 操作系统 » Linux » LINUX下高效TCP端口转发工具--RINETD

LINUX下高效TCP端口转发工具--RINETD

 

rinetd 介绍

一个C语言开发的开源TCP端口转发工具,在当前公网IP稀缺的情况下,只能通过NAT来实现内部服务器对外提供服务,该工具除了高效的实现TCP端口转发外,具有对源地址鉴权的安全功能,并且安装方便。 将TCP连接从一个IP地址和端口重定向到另一个IP地址和端口。rinetd是单进程服务,它处理配置文件中指定的地址/端口对的任意数量连接 。rinetd使用非阻塞I / O作为单个进程运行,能够重定向大量连接,同时不会对计算机造成严重影响。 rinetd 不支持重定向FTP,因为FTP需要多个套接字。

程序获取

官方地址:https://boutell.com/rinetd/ 直接下载:

# wget https://boutell.com/rinetd/http/rinetd.tar.gz

程序安装

[root@localhost src]# tar -zxvf rinetd.tar.gz  [root@localhost src]# cd rinetd  [root@localhost rinetd]# vim Makefile#修改下Makefile  CFLAGS=-DLINUX -g rinetd: rinetd.o match.o         gcc rinetd.o match.o -o rinetd install: rinetd         install -m 700 rinetd /usr/sbin         install -m 644 rinetd.8 /usr/local/share/man/man8  [root@localhost rinetd]# make && make install

主程序安装好

[root@YNCOMM4 rinetd]#  rinetd --help
Usage: rinetd [OPTION]
  -c, --conf-file FILE   read configuration from FILE
  -h, --help             display this help
  -v, --version          display version number

Most options are controlled through the
configuration file. See the rinetd(8)
manpage for more information.

配置文件

vi /etc/rinetd.con,添加如下行

0.0.0.0 8888 10.1.1.2 80 #将本机的8888端口转到内网

10.1.1.2 的80端口 allow 112.25.222.170 #只允许源地址访问该端口

启动程序

rinetd -c /etc/rinetd.conf

查看端口

原文链接:LINUX下高效TCP端口转发工具--RINETD,转载请注明来源!

4