vps交流

分享个给远程3389中转加速的nftables配置。


本帖最后由 afkool 于 2023-5-26 11:33 编辑

鉴于最近本地挂代理被请去喝茶的朋友越来越多,就把自己的母鸡给朋友开了两台3389远程挂tg聊天、刷pt用,因为太卡,又买了个9929线路中转

查了好几个,但很多编辑nftables.conf的教程我照抄了老不起作用。。后来发现了这个还挺好使,后期加端口也简单。
大佬轻喷,菜鸡拿去用。

在9929上新建配置。

  1. /etc/nftables/example.nft

复制代码

然后在

  1. /etc/nftables.conf

复制代码

文件里最底下加一行

  1. include "/etc/nftables/example.nft"

复制代码

/etc/nftables/example.nft 的文件如下图所示

  1. define localIP = 本地IP(9929、cn2)
  2. define remoteIP = 需要加速的IP(拉跨线路)
  3. define remotePort = 远程端口
  4. define localPort = 本地端口
  5. define remotePort2 = 远程端口2
  6. define localPort2 = 远程端口2
  7. #我远程和本地用一个端口。免得混淆。网上说用不一样的会有未知Bug.
  8. # Flush the rule set
  9. #flush ruleset
  10. add table ip nat
  11. add chain nat PREROUTING { type nat hook prerouting priority -100 ; }
  12. add chain nat POSTROUTING { type nat hook postrouting priority 100 ; }
  13. add rule ip nat PREROUTING tcp dport $localPort counter dnat to $remoteIP:$remotePort
  14. add rule ip nat PREROUTING udp dport $localPort counter dnat to $remoteIP:$remotePort
  15. add rule ip nat POSTROUTING ip daddr $remoteIP tcp dport $remotePort counter snat to $localIP
  16. add rule ip nat POSTROUTING ip daddr $remoteIP udp dport $remotePort counter snat to $localIP
  17. add rule ip nat PREROUTING tcp dport $localPort2 counter dnat to $remoteIP:$remotePort2
  18. add rule ip nat PREROUTING udp dport $localPort2 counter dnat to $remoteIP:$remotePort2
  19. add rule ip nat POSTROUTING ip daddr $remoteIP tcp dport $remotePort2 counter snat to $localIP
  20. add rule ip nat POSTROUTING ip daddr $remoteIP udp dport $remotePort2 counter snat to $localIP

复制代码

菜鸡收藏
赞(0)
版权声明:本贴采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
帖子名称:《分享个给远程3389中转加速的nftables配置。》
帖子链接:https://www.hostloc.xyz/244546.html