Page MenuHomeVyOS Platform

op-mode: nat rules broken
Closed, ResolvedPublicBUG

Description

While this commit supposedly fixing a typo, this left format_nat_rule undefined

vyos@vyos:~$ sho nat destination rules
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/show_nat_rules.py", line 37, in <module>
    print(format_nat_rule.format("Rule", "Source" if args.source else "Destination", "Translation", "Outbound Interface" if args.source else "Inbound Interface"))
NameError: name 'format_nat_rule' is not defined

Details

Difficulty level
Unknown (require assessment)
Version
1.4
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

Sorry, this may be my fault. It seems that I only pay attention to modifying the identifier below and forget the top definition. Sorry.

Viacheslav changed the task status from Open to Needs testing.Jun 26 2021, 2:04 PM
jack9603301 changed the subtype of this task from "Task" to "Bug".
jack9603301 moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.

Doesn't work, VyOS 1.4-rolling-202106271939

set nat destination rule 10 destination port '2222'
set nat destination rule 10 inbound-interface 'eth0'
set nat destination rule 10 protocol 'tcp'
set nat destination rule 10 translation address '192.0.2.2'
set nat destination rule 10 translation port '3456'

Show nat destination

vyos@r1-roll:~$ show nat destination rules 
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/show_nat_rules.py", line 86, in <module>
    port_range = srcdest_json['set'][0]['range']
TypeError: 'int' object is not subscriptable
Rule       Destination                                        Translation                                        Inbound Interface
----       -----------                                        -----------                                        -----------------
vyos@r1-roll:~$

Source NAT Rules went Out of Range in VyOS 1.4-rolling-202107010320

vyos@vyos:~$ sho nat sou ru
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/show_nat_rules.py", line 90, in <module>
Rule       Source                                             Translation                                        Outbound Interface
----       ------                                             -----------                                        ------------------
    tran_addr_json = dict_search('snat.addr' if args.source else 'dnat.addr', data['expr'][3])
IndexError: list index out of range

@raphielscape Are there still problems after updating PR? Please provide the configuration and I'll take the time to check it

PR: https://github.com/vyos/vyos-1x/pull/970

Merging this PR can fix this problem. Due to the complexity of the JSON parsing of NFT by the operation mode script, this task still needs to be tested, and the local test passes