diff options
author | Christian Breunig <christian@breunig.cc> | 2024-08-12 12:04:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-12 12:04:03 +0200 |
commit | e1d5cb8b56a6b103afa7326d94291e64bd2eba47 (patch) | |
tree | 04941f289854c430c58dfd57c2739443e39cdad3 /python | |
parent | 44a50ed2915371f4e967cf49768e0dd827a48018 (diff) | |
parent | ef7e8cbcdf213d04e838c89711b2f2aeb182b311 (diff) | |
download | vyos-1x-e1d5cb8b56a6b103afa7326d94291e64bd2eba47.tar.gz vyos-1x-e1d5cb8b56a6b103afa7326d94291e64bd2eba47.zip |
Merge pull request #3967 from vyos/mergify/bp/sagitta/pr-3964
T6643: firewall: fix ip address range parsing on firewall rules. (backport #3964)
Diffstat (limited to 'python')
-rwxr-xr-x[-rw-r--r--] | python/vyos/firewall.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py index d7b7b80a8..1ef42e9a3 100644..100755 --- a/python/vyos/firewall.py +++ b/python/vyos/firewall.py @@ -164,7 +164,19 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name): if address_mask: operator = '!=' if exclude else '==' operator = f'& {address_mask} {operator} ' - output.append(f'{ip_name} {prefix}addr {operator}{suffix}') + + if suffix.find('-') != -1: + # Range + start, end = suffix.split('-') + if is_ipv4(start): + output.append(f'ip {prefix}addr {operator}{suffix}') + else: + output.append(f'ip6 {prefix}addr {operator}{suffix}') + else: + if is_ipv4(suffix): + output.append(f'ip {prefix}addr {operator}{suffix}') + else: + output.append(f'ip6 {prefix}addr {operator}{suffix}') if 'fqdn' in side_conf: fqdn = side_conf['fqdn'] |