Linux安装rinetd实现TCP UDP端口转发(rinetd使用教程)
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

rinetd可较haproxy可实现UDP/TCP转发,haproxy仅能转发TCP。(以下为Centos7环境)
一、安装rinetdGithub链接:https://github.com/samhocevar/rinetd
安装依赖,编译工具
gcc是GCC中的GUN C Compiler(C 编译器)
g++是GCC中的GUN C++ Compiler(C++编译器)
以CentOS为例,安装后是没有C语言和C++编译环境的,需要手动安装
| #安装依赖 | |
| yum -y install gcc gcc-c++ make automake | |
| #下载rinetd,无法链接可看文章:https://maobuni.com/2022/06/01/linux-shell-proxy/ | |
| #或先下载后上传 | |
| wget https://github.com/samhocevar/rinetd/releases/download/v0.73/rinetd-0.73.tar.gz | |
| #解压 | |
| tar -zxvf rinetd-0.73.tar.gz | |
| #进入目录 | |
| cd rinetd-0.73 | |
| #编译安装 | |
| ./bootstrap | |
| ./configure | |
| make && make install |
rinetd配置文件的格式如下:
0.0.0.0:源IP2018:源端口192.168.1.2:目标IP2019:目标端口TCP转发文件编写格式
| #新建rinetd配置文件 | |
| vi /etc/rinetd.conf | |
| #填写如下内容,意为监听本地2022端口并转发至192.168.1.2的2023端口 | |
| 0.0.0.0 2022 192.168.1.2 2023 | |
| #以配置文件启动rinetd | |
| rinetd -c /etc/rinetd.conf |
UDP转发文件编写格式
127.0.0.1 8000/udp 192.168.1.2 8000/udp意为监听本地8000UDP端口,并转发至192.168.1.2的8000端口
三、创建systemd服务| #创建rinetd服务 | |
| vi /etc/systemd/system/rinetd.service | |
| #写入以下内容 | |
| [Unit] | |
| Description=rinetd | |
| After=network.target | |
| [Service] | |
| Type=forking | |
| ExecStart=/usr/local/sbin/rinetd -c /etc/rinetd.conf | |
| [Install] | |
| WantedBy=multi-user.target |
systemctl daemon-reload重载daemon使其生效,以下为rinetd服务管理命令
| #启动rinetd | |
| systemctl start rinetd | |
| #设置开机启动 | |
| systemctl enable rinetd | |
| #停止rinetd | |
| systemctl stop rinetd | |
| #重启 | |
| systemctl restart rinetd |
rinetd支持转发到域名,rinetd会提前解析域名,并将解析出的IP缓存到内存中,域名解析IP发生了变化必须重启rinetd才会生效更改,域名IP经常发生变化的情况下需要自己写个shell重启rinetd。
需要UDP且需要携带原始IP地址(haproxy的proxy参数),可考虑混用。可用于转发Windows remote desk。
[linux]历史优惠活动内容
猜你可能想看的VPS
- hostsolutions→充值多送 50%额度 无视 DMCA 投诉的独立服务器[U]
- 2020 年最新国外便宜 VPS 盘点全球[VPS测评]
- 8 月最后一天→VPS 半价年付 142 元起 L5630 服务器低至 全球[VPS测评]
- raksmart→日本不限流量服务器(物理机) 100Mbps 带宽 $日本VPS[主机]
- 便宜 Hostnamaste 新年优惠→虚拟主机$5 年起 VPS 年付独立服务器[U]
- Krypt ION→$2.5 月 1GB 内存 25GB SSD 空间 虚拟空间(主机)
- 腾讯云 2020 年 1 月促销:国内香港云服务器 2 核 4G6M14香港VPS[主机]
- 促销 TheStack→4 核 4G 内存 60G 硬盘 2T 流量 1全球[VPS测评]
- apache:configuration error: couldn't全球[VPS测评]
- 黑五 Virtono→全场 VPS 季付 半年付 7 折优惠 部分套餐年全球[VPS测评]
- 不限流量 OneVPS→首月 5 折 终身 9 折 多国机房 亚洲移动线全球[VPS测评]
- CombCloud 母亲节促销 7.5 折优惠,香港沙田 大浦 CN2,香港VPS[主机]
- DedeCMS 友情链接去掉 li 标签 DedeCMS 怎么去掉友情链全球[VPS测评]
- MySQL 中 alter 用法大全全球[VPS测评]
- 支付宝开发扫描生成的付款二维码提示→码已失效怎么办?全球[VPS测评]
- 如何在百度搜索结果中显示你的WordPress站点Logo全球[VPS测评]
- Cloudwebservices-2.19€ 月 荷兰 2核1G内存20全球[VPS测评]
- WordPress去掉分类链接中category目录的两种方法全球[VPS测评]
- 为什么大家都选择香港服务器建站香港VPS[主机]
- tudcloud,香港沙田大带宽vps特惠7折,CN2+BGP直连,10香港VPS[主机]
- UCloud促销:快杰云主机52元/年起,可选台湾(台北)/香港/北京/香港VPS[主机]
- 磐逸云怎么样?香港沙田cn2vps 带宽5M年付128元香港VPS[主机]
- BBR对比BBR2BBRPLUSBBR2CAKE锐速哪个效果好全球[VPS测评]
- UOVZ怎么样?香港30M大带宽VPS 直连线路月付50元香港VPS[主机]
- LOCVPS,全新香港大浦CN2 VPS 2核4G内存3M仅54/月香港VPS[主机]
- PangHost:香港CN2云服务器VPS月付29元,美国洛杉矶高防vp美国VPS[主机]
- 尊云双十二:国内4核4G5M云服务器仅28元/月,香港CN2VPS仅84香港VPS[主机]
- 又有美议员窜访台,中国驻美大使馆:“中方将对美国的挑衅采取果断的反制措施美国VPS[主机]
- 美云香港云服务器怎么样?1核1G香港云服务器价格99元/月香港VPS[主机]
- 极光KVM:1核512M/50Mbps/BGP+CN2/美西vps/年付香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-228454.html











