使用rinetd来转发端口流量|替代iptables的NAT转发

文章目录[隐藏]

rinetd简介

Rinetd是为在一个Unix和Linux操作系统中为重定向传输控制协议(TCP)连接的一个工具。Rinetd是单一过程的服务器,它处理任何数量的连接到在配置文件etc/rinetd中指定的地址/端口对。尽管rinetd使用非闭锁I/O运行作为一个单一过程,它可能重定向很多连接而不对这台机器增加额外的负担。

安装



apt install rinetd -y

配置与使用

配置文件: nano /etc/rinetd.conf



# bindadress    bindport  connectaddress  connectport

0.0.0.0 8787 172.17.5.115 8787

启动程序:



/usr/sbin/rinetd -c /etc/rinetd.conf

验证



root@PVE-EU-5 ~ # lsof -i:8787

COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME

rinetd  12046 root    4u  IPv4 2493063      0t0  TCP *:8787 (LISTEN)

示例脚本

这个是用来批量部署转发服务的:



apt install rinetd -y && \

echo '0.0.0.0 80 10.2.100.104 80' > /etc/rinetd.conf && \

echo '0.0.0.0 443 10.2.100.104 443' >> /etc/rinetd.conf && \

systemctl enable rinetd && \

systemctl restart rinetd


This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/532.html
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy