NAT tables vyos_nat and vyos_static_nat not delete after deleting nat
To reproduce
vyos@r14:~$ sudo nft list tables | match nat table ip nat vyos@r14:~$ vyos@r14:~$ conf [edit] vyos@r14# set nat source rule 100 [edit] vyos@r14# set nat source rule 100 outbound-interface eth0 [edit] vyos@r14# set nat source rule 100 translation address masquerade [edit] vyos@r14# commit [edit] vyos@r14# delete nat [edit] vyos@r14# commit [edit] vyos@r14# exit Warning: configuration changes have not been saved. exit vyos@r14:~$ vyos@r14:~$ sudo nft list tables | match nat table ip nat table ip vyos_nat table ip vyos_static_nat vyos@r14:~$
I noticed when testing "op-mode" as nft shows the different output when tables exist and do not exist
Not exist:
vyos@r14:~$ sudo nft -j list table ip vyos_nat Error: No such file or directory list table ip vyos_nat ^^^^^^^^ vyos@r14:~$
Exist:
vyos@r14:~$ sudo nft -j list table ip vyos_nat | json_pp { "nftables" : [ { "metainfo" : { "json_schema_version" : 1, "release_name" : "Lester Gooch #4", "version" : "1.0.5" } }, { "table" : { "family" : "ip", "handle" : 25, "name" : "vyos_nat" } }, { "chain" : { "family" : "ip", "handle" : 1, "hook" : "prerouting", "name" : "PREROUTING", "policy" : "accept", "prio" : -100, "table" : "vyos_nat", "type" : "nat" } }, { "chain" : { "family" : "ip", "handle" : 2, "hook" : "postrouting", "name" : "POSTROUTING", "policy" : "accept", "prio" : 100, "table" : "vyos_nat", "type" : "nat" } }, { "chain" : { "family" : "ip", "handle" : 3, "name" : "VYOS_PRE_DNAT_HOOK", "table" : "vyos_nat" } }, { "chain" : { "family" : "ip", "handle" : 4, "name" : "VYOS_PRE_SNAT_HOOK", "table" : "vyos_nat" } }, { "rule" : { "chain" : "PREROUTING", "expr" : [ { "counter" : { "bytes" : 0, "packets" : 0 } }, { "jump" : { "target" : "VYOS_PRE_DNAT_HOOK" } } ], "family" : "ip", "handle" : 5, "table" : "vyos_nat" } }, { "rule" : { "chain" : "POSTROUTING", "expr" : [ { "counter" : { "bytes" : 0, "packets" : 0 } }, { "jump" : { "target" : "VYOS_PRE_SNAT_HOOK" } } ], "family" : "ip", "handle" : 6, "table" : "vyos_nat" } }, { "rule" : { "chain" : "POSTROUTING", "comment" : "SRC-NAT-100", "expr" : [ { "match" : { "left" : { "meta" : { "key" : "oifname" } }, "op" : "==", "right" : "eth0" } }, { "counter" : { "bytes" : 0, "packets" : 0 } }, { "masquerade" : null } ], "family" : "ip", "handle" : 7, "table" : "vyos_nat" } }, { "rule" : { "chain" : "VYOS_PRE_DNAT_HOOK", "expr" : [ { "return" : null } ], "family" : "ip", "handle" : 8, "table" : "vyos_nat" } }, { "rule" : { "chain" : "VYOS_PRE_SNAT_HOOK", "expr" : [ { "return" : null } ], "family" : "ip", "handle" : 9, "table" : "vyos_nat" } } ] } vyos@r14:~$
I think we should delete tables vyos_nat and vyos_static_nat if nat configuration does not exist