问题原文
原帖链接 · ro-friday · CC BY-SA 4.0
using nftables, I need to NAT an entire subnet to another one for example:
10.10.10.1 -> 10.200.0.1
10.10.10.2 -> 10.200.0.2
...
10.10.10.X -> 10.200.0.X
nftables docs here shows multiple NATs in one line, but how can I manage that use case if my subnet is /24 or bigger? Do I have to list hundreds of addresses manually?
I've looked documentation and examples but didn't found a solution.
Than you very much in advance.
Regards.
已采纳解答
原帖链接 · Tom Yan · CC BY-SA 4.0
For now you can do it with bitwise operation:
ip saddr 10.10.10.0/24 snat to ip saddr & 255.0.0.255 | 0.200.0.0
"Proper" support is already in git.
UPDATE: apparently the "proper" syntax is as follows:
snat ip prefix to ip saddr map { 10.10.10.0/24 : 10.200.0.0/24 }
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
