summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-05-22 19:48:32 +0200
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-05-22 18:02:03 +0000
commita2293874c80d99c77930cfd47daffe9e6ab84d3a (patch)
treee26db54681d9c2a1e86d82eed3cacbd3f3b4fcc6 /src/conf_mode
parent50e7577815ca2e2da80a0356815d421350df63f5 (diff)
downloadvyos-1x-a2293874c80d99c77930cfd47daffe9e6ab84d3a.tar.gz
vyos-1x-a2293874c80d99c77930cfd47daffe9e6ab84d3a.zip
nat: T6365: use interface_exists() over netifaces.interfaces()
(cherry picked from commit 645c43ba60d29ca676a4323ccc5ca16c6bd8127a)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/nat.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/conf_mode/nat.py b/src/conf_mode/nat.py
index db02ca66f..f74bb217e 100755
--- a/src/conf_mode/nat.py
+++ b/src/conf_mode/nat.py
@@ -17,7 +17,6 @@
import os
from sys import exit
-from netifaces import interfaces
from vyos.base import Warning
from vyos.config import Config
@@ -30,6 +29,7 @@ from vyos.utils.dict import dict_search_args
from vyos.utils.process import cmd
from vyos.utils.process import run
from vyos.utils.network import is_addr_assigned
+from vyos.utils.network import interface_exists
from vyos import ConfigError
from vyos import airbag
@@ -153,8 +153,8 @@ def verify(nat):
if interface_name not in 'any':
if interface_name.startswith('!'):
interface_name = interface_name[1:]
- if interface_name not in interfaces():
- Warning(f'NAT interface "{interface_name}" for source NAT rule "{rule}" does not exist!')
+ if not interface_exists(interface_name):
+ Warning(f'Interface "{interface_name}" for source NAT rule "{rule}" does not exist!')
else:
group_name = config['outbound_interface']['group']
if group_name[0] == '!':
@@ -190,8 +190,8 @@ def verify(nat):
if interface_name not in 'any':
if interface_name.startswith('!'):
interface_name = interface_name[1:]
- if interface_name not in interfaces():
- Warning(f'NAT interface "{interface_name}" for destination NAT rule "{rule}" does not exist!')
+ if not interface_exists(interface_name):
+ Warning(f'Interface "{interface_name}" for destination NAT rule "{rule}" does not exist!')
else:
group_name = config['inbound_interface']['group']
if group_name[0] == '!':