大网数据广告活动
服务器运维问答

iptables-like NETMAP with nftables

· 52CE 我爱测

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 th…

问题原文

原帖链接 · 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 }

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-05-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。