rinetd端口转发

 

1.下载软件包
2.解压安装rinetd
tar zxvf rinetd.tar.gz
cd rinetd
./configure --prefix=/usr/local/rinetd
make && make install

3.配置启动管理
cat >> /lib/systemd/system/rinetd.service << EOF
[Unit]
Description=Rinetd Daemon
After=network.service
Wants=network.service
[Service]
Type=forking
PIDFile=/var/run/rinetd.pid
ExecStart=/usr/local/rinetd/sbin/rinetd -c /usr/local/rinetd/etc/rinetd.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF

4.配置文件编写
# vim /usr/local/rinetd/etc/rinetd.conf
0.0.0.0 3306 192.168.1.130 3306

logfile /var/log/rinetd.log



5.参数解释(可以是ip也可以是域名,也可以是外网ip[一般不转发到外网])

0.0.0.0 3306 192.168.1.155 3306 
0.0.0.0                   --- 源IP
3306                      --- 源端口
192.168.1.130       --- 目标IP
3306                      --- 目标端口
上面配置的意思是将本机3306端口转发到192.168.1.155的3306端口


6.启动服务
systemctl  daemon-reload
systemctl enable rinetd.service
systemctl start/stop rinetd.service

  

posted @ 2022-06-26 11:56  Leonardo-li  阅读(406)  评论(0编辑  收藏  举报