端口转发,可以代替teamviewer
服务器内网ip为192.168.195.128,10.1.41.111
客户端ip 10.1.41.3
远程服务端为 192.168.195.132
通过端口转发,实现访问服务器的10.1.41.111 的63497端口,然后转发到192.168.195.132的3389端口,实现远程桌面的登录
操作如下:
yum install gcc gcc-c++ -y wget http://www.boutell.com/rinetd/http/rinetd.tar.gz tar -xvf rinetd.tar.gz && cd rinetd && mkdir /usr/man/man8 -pv && make && make install
编辑配置文件
vim /etc/rinetd.conf
10.1.41.111 63497 192.168.195.132 3389
启动程序
rinetd -c /etc/rinetd.conf
远程连接测试
写成服务如下
vim /etc/rinetd.conf
#!/bin/bash
# chkconfig: 2345 88 12
# description: rinetd
RINETD=/usr/sbin/rinetd
RINETDCONF=/etc/rinetd.conf
PID=ps aux | grep rinetd | grep -v "grep" | awk -F" " '/\/sbin\/rinetd/{print $2}'
if [ -e $RINETDCONF ]; then
echo "ok" &> /dev/null
else
echo "Configuration file not found"
exit 1
fi
case "$1" in
start)
echo -n "Starting rinetd..."
$RINETD -c $RINETDCONF &>/dev/null
echo " done."
;;
stop)
echo -n "Stopping rinetd..."
kill -9 $PID &>/dev/null
echo " done."
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 start|stop|restart"
;;
esac
exit 0
授执行权限并加入开机启动
chmod a+x /etc/init.d/rinetd chkconfig --add rinetd chkconfig rinetd on