diff options
author | Christian Breunig <christian@breunig.cc> | 2023-09-16 12:57:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-16 12:57:57 +0200 |
commit | 8f79a5cb4ee9b6eb5e825304702558fd5db791df (patch) | |
tree | 27f861dd70a0988517b6fadae089972bc133cb5d /src | |
parent | 50bbac2a4227ab75973f619b527f24f36e11dc14 (diff) | |
parent | 1c747d1d1e023bf041afa01b6a18166d15b46d8e (diff) | |
download | vyos-1x-8f79a5cb4ee9b6eb5e825304702558fd5db791df.tar.gz vyos-1x-8f79a5cb4ee9b6eb5e825304702558fd5db791df.zip |
Merge pull request #2267 from vyos/mergify/bp/sagitta/pr-2253
T5561: nat: inbound|outbound interface should not be mandatory (backport #2253)
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/nat.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/conf_mode/nat.py b/src/conf_mode/nat.py index 9da7fbe80..ebc434da9 100755 --- a/src/conf_mode/nat.py +++ b/src/conf_mode/nat.py @@ -195,11 +195,10 @@ def verify(nat): if dict_search('source.rule', nat): for rule, config in dict_search('source.rule', nat).items(): err_msg = f'Source NAT configuration error in rule {rule}:' - if 'outbound_interface' not in config: - raise ConfigError(f'{err_msg} outbound-interface not specified') - if config['outbound_interface'] not in 'any' and config['outbound_interface'] not in interfaces(): - Warning(f'rule "{rule}" interface "{config["outbound_interface"]}" does not exist on this system') + if 'outbound_interface' in config: + if config['outbound_interface'] not in 'any' and config['outbound_interface'] not in interfaces(): + Warning(f'rule "{rule}" interface "{config["outbound_interface"]}" does not exist on this system') if not dict_search('translation.address', config) and not dict_search('translation.port', config): if 'exclude' not in config and 'backend' not in config['load_balance']: @@ -218,11 +217,9 @@ def verify(nat): for rule, config in dict_search('destination.rule', nat).items(): err_msg = f'Destination NAT configuration error in rule {rule}:' - if 'inbound_interface' not in config: - raise ConfigError(f'{err_msg}\n' \ - 'inbound-interface not specified') - elif config['inbound_interface'] not in 'any' and config['inbound_interface'] not in interfaces(): - Warning(f'rule "{rule}" interface "{config["inbound_interface"]}" does not exist on this system') + if 'inbound_interface' in config: + if config['inbound_interface'] not in 'any' and config['inbound_interface'] not in interfaces(): + Warning(f'rule "{rule}" interface "{config["inbound_interface"]}" does not exist on this system') if not dict_search('translation.address', config) and not dict_search('translation.port', config) and 'redirect' not in config['translation']: if 'exclude' not in config and 'backend' not in config['load_balance']: |