- 本项目支持转发到ddns域名、支持udp转发,但不支持端口段转发
- 很多玩VPS的人都会有设置端口转发、进行中转的需求,在这方面也有若干种方案,比如socat、haproxy、brook等等。他们都有一些局限或者问题,比如socat会爆内存,haproxy不支持udp转发。
- 我比较喜欢iptables。iptables利用linux的一个内核模块进行ip包的转发,工作在linux的内核态,不涉及内核态和用户态的状态转换,因此可以说是所有端口转发方案中最稳定的。但他的缺点也显而易见:只支持IP、需要输入一大堆参数。本项目就是为了解决这些缺点,让大家能方便快速地使用最快、最稳定的端口转发方案。
先安装iptables
先 停止firewalld服务、禁用firewalld服务
systemctl stop firewalld systemctl mask firewalld systemctl disable firewalld
安装iptables iptables-service。
yum install -y iptables yum update iptables yum install iptables-services
开启iptables服务,并设置开机启动
systemctl start iptables systemctl enable iptables
最后检查一下
iptables
的活动状态。service iptables status
用法
wget -qO natcfg.sh https://raw.githubusercontent.com/arloor/iptablesUtils/master/natcfg.sh && bash natcfg.sh
bash natcfg.sh
或
wget -qO natcfg.sh https://raw.githubusercontent.com/yangyzp/iptablesUtils/master/natcfg.sh && bash natcfg.sh
bash natcfg.sh
SSPanel 上的节点配置
原文地址:https://github.com/arloor/iptablesUtils
iptables开放指定端口
- 1.找到配置文件
/etc/sysconfig/iptables
,编辑 2.在配置文件中添加开放端口代码(一定要在22端口这段代码下添加,否则可能无效)
-A INPUT -p tcp --dport 1001 -j ACCEPT -A INPUT -p udp --dport 1001 -j ACCEPT
3.重启iptables生效
service iptables restart
sspanel端口指定、端口偏移
1.端口指定
- 单个端口指定,节点地址格式:8.8.8.8;port=80#10080
- 多个端口指定,节点地址格式:8.8.8.8;port=80#10080+443#10443
- 以上指定会在面板和订阅中将原节点端口 80 替换为 10080,443 替换为 10443,更多请使用加号分隔。
- 例子:(原版单端口1001变成了1234)
1.端口偏移
- 端口偏移,节点地址格式:8.8.8.8;port=1000 or 8.8.8.8;port=-1000
原文地址:http://www.mipuo.com/3007.html