From 08699a10ccea1ea428b856d7b3dd7644d66ea699 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Wed, 3 Aug 2022 12:55:58 +0000 Subject: validators: T4586: Add IPv6 exclude validators for address/prefix Add IPV6 exclude validators: - ipv6-address-exclude - ipv6-prefix-exclude Will use in nat66 source/destination --- src/validators/ipv6-address-exclude | 7 +++++++ src/validators/ipv6-prefix-exclude | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100755 src/validators/ipv6-address-exclude create mode 100755 src/validators/ipv6-prefix-exclude diff --git a/src/validators/ipv6-address-exclude b/src/validators/ipv6-address-exclude new file mode 100755 index 000000000..be1d3db25 --- /dev/null +++ b/src/validators/ipv6-address-exclude @@ -0,0 +1,7 @@ +#!/bin/sh +arg="$1" +if [ "${arg:0:1}" != "!" ]; then + exit 1 +fi +path=$(dirname "$0") +${path}/ipv6-address "${arg:1}" diff --git a/src/validators/ipv6-prefix-exclude b/src/validators/ipv6-prefix-exclude new file mode 100755 index 000000000..6fa4f1d8d --- /dev/null +++ b/src/validators/ipv6-prefix-exclude @@ -0,0 +1,7 @@ +#!/bin/sh +arg="$1" +if [ "${arg:0:1}" != "!" ]; then + exit 1 +fi +path=$(dirname "$0") +${path}/ipv6-prefix "${arg:1}" -- cgit v1.2.3 From ecc03bd6e499bfa071218aa70d325fcfcc191dec Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Wed, 3 Aug 2022 12:58:24 +0000 Subject: nat66: T4586: Add SNAT destination prefix and DNAT address Ability to configure SNAT destination prefix and DNAT source address Add option "!" - not address/prefix for NAT66 --- data/templates/firewall/nftables-nat66.j2 | 12 ++++- interface-definitions/nat66.xml.in | 73 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/data/templates/firewall/nftables-nat66.j2 b/data/templates/firewall/nftables-nat66.j2 index 003b138b2..ca19506f2 100644 --- a/data/templates/firewall/nftables-nat66.j2 +++ b/data/templates/firewall/nftables-nat66.j2 @@ -3,8 +3,10 @@ {% macro nptv6_rule(rule,config, chain) %} {% set comment = '' %} {% set base_log = '' %} -{% set src_prefix = 'ip6 saddr ' ~ config.source.prefix if config.source.prefix is vyos_defined %} -{% set dest_address = 'ip6 daddr ' ~ config.destination.address if config.destination.address is vyos_defined %} +{% set dst_prefix = 'ip6 daddr ' ~ config.destination.prefix.replace('!','!= ') if config.destination.prefix is vyos_defined %} +{% set src_prefix = 'ip6 saddr ' ~ config.source.prefix.replace('!','!= ') if config.source.prefix is vyos_defined %} +{% set source_address = 'ip6 saddr ' ~ config.source.address.replace('!','!= ') if config.source.address is vyos_defined %} +{% set dest_address = 'ip6 daddr ' ~ config.destination.address.replace('!','!= ') if config.destination.address is vyos_defined %} {% if chain is vyos_defined('PREROUTING') %} {% set comment = 'DST-NAT66-' ~ rule %} {% set base_log = '[NAT66-DST-' ~ rule %} @@ -52,6 +54,12 @@ {% if src_prefix is vyos_defined %} {% set output = output ~ ' ' ~ src_prefix %} {% endif %} +{% if dst_prefix is vyos_defined %} +{% set output = output ~ ' ' ~ dst_prefix %} +{% endif %} +{% if source_address is vyos_defined %} +{% set output = output ~ ' ' ~ source_address %} +{% endif %} {% if dest_address is vyos_defined %} {% set output = output ~ ' ' ~ dest_address %} {% endif %} diff --git a/interface-definitions/nat66.xml.in b/interface-definitions/nat66.xml.in index b47f653c6..ac3198f45 100644 --- a/interface-definitions/nat66.xml.in +++ b/interface-definitions/nat66.xml.in @@ -49,6 +49,30 @@ + + + IPv6 destination prefix options + + + + + IPv6 prefix to be translated + + ipv6net + IPv6 prefix + + + !ipv6net + Match everything except the specified IPv6 prefix + + + + + + + + + IPv6 source prefix options @@ -61,8 +85,13 @@ ipv6net IPv6 prefix + + !ipv6net + Match everything except the specified IPv6 prefix + + @@ -164,9 +193,53 @@ ipv6net IPv6 prefix + + !ipv6 + Match everything except the specified IPv6 address + + + !ipv6net + Match everything except the specified IPv6 prefix + + + + + + + + + + + + + + IPv6 source prefix options + + + + + IPv6 address or prefix to be translated + + ipv6 + IPv6 address + + + ipv6net + IPv6 prefix + + + !ipv6 + Match everything except the specified IPv6 address + + + !ipv6net + Match everything except the specified IPv6 prefix + + + -- cgit v1.2.3