12

linux实现端口映射转发

2017-08-17 13:01:00    1147533288    1427    转贴:新浪博客
摘要:端口映射,解决内外网不通问题

亲测,好用的一塌糊涂,比windows下面的端口映射工具还方便


wget http://www.boutell.com/rinetd/http/rinetd.tar.gz

 
1.安装软件:
tar xzvf rinetd.tar.gz
cd rinetd
make
make install
ps:执行make install时可能出现错误:缺少目录/usr/man/man8,此时执行 makedir -p /uar/man/man8即可
 

创建配置文件:

touch /etc/rinetd.conf

vi /etc/rinetd.conf
0.0.0.0 8080 2.2.2.2 80
ps:本机8080端口需要确认未被使用:netstat -antp | grep 8080 | grep -v grep
 
启动rinetd:
rinetd -c /etc/rinetd.conf
ps:需要确认进程中没有rinetd:ps ax | grep rinetd | grep -v grep,如果有的话,需要删除该进程:pkill rinetd
 
配置文件格式:
bindaddress bindport connectaddress connectport
绑定的地址  绑定的端口  转发的地址  转发的端口
0.0.0.0 8080 2.2.2.2 80
将所有发往本机的8080端口的请求转发到2.2.2.2的80端口
1.1.1.1 8080 2.2.2.2 80
将所有发往1.1.1.1的8080端口的请求转发到2.2.2.2的80端口
苏ICP备18038013号-1
蝉知 蝉知5.2