2

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.

ro-friday
  • 23
  • 5

1 Answers1

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 }
Tom Yan
  • 747
  • 3
  • 9