From 35a6b10c1bc488ca195e9c641563c29251f725f3 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 24 Apr 2020 21:56:51 +0200 Subject: src: add netmap support This patch allows you to specify an interval of IP address in maps. table ip x { chain y { type nat hook postrouting priority srcnat; policy accept; snat ip prefix to ip saddr map { 10.141.11.0/24 : 192.168.2.0/24 } } } The example above performs SNAT to packets that comes from 10.141.11.0/24 using the prefix 192.168.2.0/24, e.g. 10.141.11.4 is mangled to 192.168.2.4. Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 731a5b3e..3b470cc6 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -3205,6 +3205,23 @@ nat_stmt_args : stmt_expr $0->nat.addr = $3; $0->nat.type_flags = STMT_NAT_F_INTERVAL; } + | nf_key_proto PREFIX TO stmt_expr + { + $0->nat.family = $1; + $0->nat.addr = $4; + $0->nat.type_flags = + STMT_NAT_F_PREFIX | + STMT_NAT_F_INTERVAL; + $0->nat.flags |= NF_NAT_RANGE_NETMAP; + } + | PREFIX TO stmt_expr + { + $0->nat.addr = $3; + $0->nat.type_flags = + STMT_NAT_F_PREFIX | + STMT_NAT_F_INTERVAL; + $0->nat.flags |= NF_NAT_RANGE_NETMAP; + } ; masq_stmt : masq_stmt_alloc masq_stmt_args -- cgit v1.2.3