Destination NAT for netmap. Validation error

I was trying to create a Destination NAT with a NETMAP where two equal sized networks are NAT’ed… It doesn’t seem to work. It’s a new feature after nftables was adopted.

vyos@vyos# commit
[ nat ]
VyOS had an issue completing a command.

We are sorry that you encountered a problem while using VyOS.
There are a few things you can do to help us (and yourself):

When reporting problems, please include as much information as possible:

  • do not obfuscate any data (feel free to contact us privately if your
    business policy requires it)
  • and include all the information presented below

Report Time: 2021-02-11 16:58:43
Image Version: VyOS 1.4-rolling-202102100753
Release Train: sagitta

Built by: autobuild@vyos.net
Built on: Wed 10 Feb 2021 07:54 UTC
Build UUID: b99c3240-c9a7-4f01-ac6c-c1d2e4748c2b
Build Commit ID: aec60effa4e36e

Architecture: x86_64
Boot via: installed image
System type: KVM guest

Hardware vendor: QEMU
Hardware model: Standard PC (Q35 + ICH9, 2009)
Hardware S/N:
Hardware UUID: 02d26e80-76c2-41d3-902c-0cf0f99280fc

Traceback (most recent call last):
File “/usr/libexec/vyos/conf_mode/nat.py”, line 201, in
generate©
File “/usr/libexec/vyos/conf_mode/nat.py”, line 186, in generate
permission=0o755)
File “/usr/lib/python3/dist-packages/vyos/template.py”, line 112, in render
rendered = render_to_string(template, content, formater)
File “/usr/lib/python3/dist-packages/vyos/template.py”, line 82, in render_to_string
rendered = template.render(content)
File “/usr/lib/python3/dist-packages/jinja2/asyncsupport.py”, line 76, in render
return original_render(self, *args, **kwargs)
File “/usr/lib/python3/dist-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/usr/lib/python3/dist-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python3/dist-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “/usr/share/vyos/templates/firewall/nftables-nat.tmpl”, line 148, in top-level template code
{{ nat_rule(rule, config, ‘PREROUTING’) }}
File “/usr/lib/python3/dist-packages/jinja2/runtime.py”, line 579, in _invoke
rv = self._func(*arguments)
File “/usr/share/vyos/templates/firewall/nftables-nat.tmpl”, line 27, in template
{% set trns_addr = ‘dnat ip prefix to ip daddr map { ’ + config.source.address + ’ : ’ + config.translation.address + ’ }’ %}
File “/usr/lib/python3/dist-packages/jinja2/environment.py”, line 430, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: ‘dict object’ has no attribute ‘source’

[[nat]] failed
Commit failed
[edit]
vyos@vyos# compare
[edit nat]
+destination {

  • rule 100 {
  •    destination {
    
  •        address 10.0.0.128/25
    
  •    }
    
  •    inbound-interface wg01
    
  •    translation {
    
  •        address 10.1.1.128/25
    
  •    }
    
  • }
    +}
    [edit]

Hello @joolli. I see that the bug report already created https://phabricator.vyos.net/T3307 and patch committed https://github.com/vyos/vyos-1x/pull/731
Thanks!

1 Like