全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1130|回复: 1

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

[复制链接]
发表于 2023-5-26 11:33:17 | 显示全部楼层 |阅读模式
本帖最后由 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
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-4-12 18:50 , Processed in 0.061537 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表