首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
V2EX
›
程序员
如何使用 nftables 进行多端口的转发!
codersdp1
·
144 天前
· 1079 次点击
这是一个创建于 144 天前的主题,其中的信息可能已经有所发展或是发生改变。
比如将本机(192.168.66.142)的 22000 端口 转发 目标机器(192.168.66.143)的 20000 端口
22001 端口 转发 目标机器的 20001 端口
22002 端口 转发 目标机器的 20002 端口
...
24000 端口 转发 目标机器的 22000 端口
端口关系是-2000
SNAT 只写一条就好了
ip daddr 192.168.66.143 tcp dport 20000-22000 counter snat to 192.168.66.142
DNAT 得写 2000 条
nft add rule ip nat prerouting tcp dport 22001 counter dnat to 192.168.66.143:20001
nft add rule ip nat prerouting tcp dport 22002 counter dnat to 192.168.66.143:20002
......
DNAT 写 2k 条太影响性能了,有更好的方式了??
nftables
转发
性能
5 条回复
•
2024-11-20 19:50:22 +08:00
1
LGA1150
144 天前 via Android
1
https://wiki.nftables.org/wiki-nftables/index.php/Maps
用 Anonymous map
2
xqzr
144 天前
1
ip daddr 192.168.66.142 dnat to tcp dport map { 22001 : 192.168.66.143 . 20001, 22002 : 192.168.66.143 . 20002 }
3
codersdp1
OP
144 天前
也知道使用 MAP ,但不知道怎么写。
4
codersdp1
OP
144 天前
@
xqzr
这个 192.168.66.143 . 20001 会有语法错误
5
codersdp1
OP
144 天前
@
xqzr
可以了,谢谢大哥
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
1628 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 21ms ·
UTC 16:26
·
PVG 00:26
·
LAX 09:26
·
JFK 12:26
Developed with
CodeLauncher
♥ Do have faith in what you're doing.