diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py
index 6508ccdd9..894dc3286 100644
--- a/python/vyos/configverify.py
+++ b/python/vyos/configverify.py
@@ -1,489 +1,490 @@
 # Copyright 2020-2024 VyOS maintainers and contributors <maintainers@vyos.io>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
 # version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
 # The sole purpose of this module is to hold common functions used in
 # all kinds of implementations to verify the CLI configuration.
 # It is started by migrating the interfaces to the new get_config_dict()
 # approach which will lead to a lot of code that can be reused.
 
 # NOTE: imports should be as local as possible to the function which
 # makes use of it!
 
 from vyos import ConfigError
 from vyos.utils.dict import dict_search
 from vyos.utils.dict import dict_search_recursive
 
 # pattern re-used in ipsec migration script
 dynamic_interface_pattern = r'(ppp|pppoe|sstpc|l2tp|ipoe)[0-9]+'
 
 def verify_mtu(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation if the specified MTU can be used by the underlaying
     hardware.
     """
     from vyos.ifconfig import Interface
     if 'mtu' in config:
         mtu = int(config['mtu'])
 
         tmp = Interface(config['ifname'])
         # Not all interfaces support min/max MTU
         # https://vyos.dev/T5011
         try:
             min_mtu = tmp.get_min_mtu()
             max_mtu = tmp.get_max_mtu()
         except: # Fallback to defaults
             min_mtu = 68
             max_mtu = 9000
 
         if mtu < min_mtu:
             raise ConfigError(f'Interface MTU too low, ' \
                               f'minimum supported MTU is {min_mtu}!')
         if mtu > max_mtu:
             raise ConfigError(f'Interface MTU too high, ' \
                               f'maximum supported MTU is {max_mtu}!')
 
 def verify_mtu_parent(config, parent):
     if 'mtu' not in config or 'mtu' not in parent:
         return
 
     mtu = int(config['mtu'])
     parent_mtu = int(parent['mtu'])
     if mtu > parent_mtu:
         raise ConfigError(f'Interface MTU ({mtu}) too high, ' \
                           f'parent interface MTU is {parent_mtu}!')
 
 def verify_mtu_ipv6(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation if the specified MTU can be used when IPv6 is
     configured on the interface. IPv6 requires a 1280 bytes MTU.
     """
     from vyos.template import is_ipv6
     if 'mtu' in config:
         # IPv6 minimum required link mtu
         min_mtu = 1280
         if int(config['mtu']) < min_mtu:
             interface = config['ifname']
             error_msg = f'IPv6 address will be configured on interface "{interface}",\n' \
                         f'the required minimum MTU is {min_mtu}!'
 
             if 'address' in config:
                 for address in config['address']:
                     if address in ['dhcpv6'] or is_ipv6(address):
                         raise ConfigError(error_msg)
 
             tmp = dict_search('ipv6.address.no_default_link_local', config)
             if tmp == None: raise ConfigError('link-local ' + error_msg)
 
             tmp = dict_search('ipv6.address.autoconf', config)
             if tmp != None: raise ConfigError(error_msg)
 
             tmp = dict_search('ipv6.address.eui64', config)
             if tmp != None: raise ConfigError(error_msg)
 
 def verify_vrf(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation of VRF configuration.
     """
     from netifaces import interfaces
     if 'vrf' in config and config['vrf'] != 'default':
         if config['vrf'] not in interfaces():
             raise ConfigError('VRF "{vrf}" does not exist'.format(**config))
 
         if 'is_bridge_member' in config:
             raise ConfigError(
                 'Interface "{ifname}" cannot be both a member of VRF "{vrf}" '
                 'and bridge "{is_bridge_member}"!'.format(**config))
 
 def verify_bond_bridge_member(config):
     """
     Checks if interface has a VRF configured and is also part of a bond or
     bridge, which is not allowed!
     """
     if 'vrf' in config:
         ifname = config['ifname']
         if 'is_bond_member' in config:
             raise ConfigError(f'Can not add interface "{ifname}" to bond, it has a VRF assigned!')
         if 'is_bridge_member' in config:
             raise ConfigError(f'Can not add interface "{ifname}" to bridge, it has a VRF assigned!')
 
 def verify_tunnel(config):
     """
     This helper is used to verify the common part of the tunnel
     """
     from vyos.template import is_ipv4
     from vyos.template import is_ipv6
 
     if 'encapsulation' not in config:
         raise ConfigError('Must configure the tunnel encapsulation for '\
                           '{ifname}!'.format(**config))
 
     if 'source_address' not in config and 'source_interface' not in config:
         raise ConfigError('source-address or source-interface required for tunnel!')
 
     if 'remote' not in config and config['encapsulation'] != 'gre':
         raise ConfigError('remote ip address is mandatory for tunnel')
 
     if config['encapsulation'] in ['ipip6', 'ip6ip6', 'ip6gre', 'ip6gretap', 'ip6erspan']:
         error_ipv6 = 'Encapsulation mode requires IPv6'
         if 'source_address' in config and not is_ipv6(config['source_address']):
             raise ConfigError(f'{error_ipv6} source-address')
 
         if 'remote' in config and not is_ipv6(config['remote']):
             raise ConfigError(f'{error_ipv6} remote')
     else:
         error_ipv4 = 'Encapsulation mode requires IPv4'
         if 'source_address' in config and not is_ipv4(config['source_address']):
             raise ConfigError(f'{error_ipv4} source-address')
 
         if 'remote' in config and not is_ipv4(config['remote']):
             raise ConfigError(f'{error_ipv4} remote address')
 
     if config['encapsulation'] in ['sit', 'gretap', 'ip6gretap']:
         if 'source_interface' in config:
             encapsulation = config['encapsulation']
             raise ConfigError(f'Option source-interface can not be used with ' \
                               f'encapsulation "{encapsulation}"!')
     elif config['encapsulation'] == 'gre':
         if 'source_address' in config and is_ipv6(config['source_address']):
             raise ConfigError('Can not use local IPv6 address is for mGRE tunnels')
 
 def verify_eapol(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation of EAPoL configuration.
     """
     if 'eapol' in config:
         if 'certificate' not in config['eapol']:
             raise ConfigError('Certificate must be specified when using EAPoL!')
 
         if 'pki' not in config or 'certificate' not in config['pki']:
             raise ConfigError('Invalid certificate specified for EAPoL')
 
         cert_name = config['eapol']['certificate']
         if cert_name not in config['pki']['certificate']:
             raise ConfigError('Invalid certificate specified for EAPoL')
 
         cert = config['pki']['certificate'][cert_name]
 
         if 'certificate' not in cert or 'private' not in cert or 'key' not in cert['private']:
             raise ConfigError('Invalid certificate/private key specified for EAPoL')
 
         if 'password_protected' in cert['private']:
             raise ConfigError('Encrypted private key cannot be used for EAPoL')
 
         if 'ca_certificate' in config['eapol']:
             if 'ca' not in config['pki']:
                 raise ConfigError('Invalid CA certificate specified for EAPoL')
 
             for ca_cert_name in config['eapol']['ca_certificate']:
                 if ca_cert_name not in config['pki']['ca']:
                     raise ConfigError('Invalid CA certificate specified for EAPoL')
 
                 ca_cert = config['pki']['ca'][ca_cert_name]
 
                 if 'certificate' not in ca_cert:
                     raise ConfigError('Invalid CA certificate specified for EAPoL')
 
 def verify_mirror_redirect(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation of mirror and redirect interface configuration via tc(8)
 
     It makes no sense to mirror traffic back at yourself!
     """
-    import os
+    from vyos.utils.network import interface_exists
     if {'mirror', 'redirect'} <= set(config):
         raise ConfigError('Mirror and redirect can not be enabled at the same time!')
 
     if 'mirror' in config:
         for direction, mirror_interface in config['mirror'].items():
-            if not os.path.exists(f'/sys/class/net/{mirror_interface}'):
+            if not interface_exists(mirror_interface):
                 raise ConfigError(f'Requested mirror interface "{mirror_interface}" '\
                                    'does not exist!')
 
             if mirror_interface == config['ifname']:
                 raise ConfigError(f'Can not mirror "{direction}" traffic back '\
                                    'the originating interface!')
 
     if 'redirect' in config:
         redirect_ifname = config['redirect']
-        if not os.path.exists(f'/sys/class/net/{redirect_ifname}'):
+        if not interface_exists(redirect_ifname):
             raise ConfigError(f'Requested redirect interface "{redirect_ifname}" '\
                                'does not exist!')
 
     if ('mirror' in config or 'redirect' in config) and dict_search('traffic_policy.in', config) is not None:
         # XXX: support combination of limiting and redirect/mirror - this is an
         # artificial limitation
         raise ConfigError('Can not use ingress policy together with mirror or redirect!')
 
 def verify_authentication(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation of authentication for either PPPoE or WWAN interfaces.
 
     If authentication CLI option is defined, both username and password must
     be set!
     """
     if 'authentication' not in config:
         return
     if not {'username', 'password'} <= set(config['authentication']):
         raise ConfigError('Authentication requires both username and ' \
                           'password to be set!')
 
 def verify_address(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation of IP address assignment when interface is part
     of a bridge or bond.
     """
     if {'is_bridge_member', 'address'} <= set(config):
         interface = config['ifname']
         bridge_name = next(iter(config['is_bridge_member']))
         raise ConfigError(f'Cannot assign address to interface "{interface}" '
                           f'as it is a member of bridge "{bridge_name}"!')
 
 def verify_bridge_delete(config):
     """
     Common helper function used by interface implementations to
     perform recurring validation of IP address assignmenr
     when interface also is part of a bridge.
     """
     if 'is_bridge_member' in config:
         interface = config['ifname']
         bridge_name = next(iter(config['is_bridge_member']))
         raise ConfigError(f'Interface "{interface}" cannot be deleted as it '
                           f'is a member of bridge "{bridge_name}"!')
 
 def verify_interface_exists(ifname, warning_only=False):
     """
     Common helper function used by interface implementations to perform
     recurring validation if an interface actually exists. We first probe
     if the interface is defined on the CLI, if it's not found we try if
     it exists at the OS level.
     """
     import os
     from vyos.base import Warning
     from vyos.configquery import ConfigTreeQuery
     from vyos.utils.dict import dict_search_recursive
+    from vyos.utils.network import interface_exists
 
     # Check if interface is present in CLI config
     config = ConfigTreeQuery()
     tmp = config.get_config_dict(['interfaces'], get_first_key=True)
     if bool(list(dict_search_recursive(tmp, ifname))):
         return True
 
     # Interface not found on CLI, try Linux Kernel
-    if os.path.exists(f'/sys/class/net/{ifname}'):
+    if interface_exists(ifname):
         return True
 
     message = f'Interface "{ifname}" does not exist!'
     if warning_only:
         Warning(message)
         return False
     raise ConfigError(message)
 
 def verify_source_interface(config):
     """
     Common helper function used by interface implementations to
     perform recurring validation of the existence of a source-interface
     required by e.g. peth/MACvlan, MACsec ...
     """
     import re
     from netifaces import interfaces
 
     ifname = config['ifname']
     if 'source_interface' not in config:
         raise ConfigError(f'Physical source-interface required for "{ifname}"!')
 
     src_ifname = config['source_interface']
     # We do not allow sourcing other interfaces (e.g. tunnel) from dynamic interfaces
     tmp = re.compile(dynamic_interface_pattern)
     if tmp.match(src_ifname):
         raise ConfigError(f'Can not source "{ifname}" from dynamic interface "{src_ifname}"!')
 
     if src_ifname not in interfaces():
         raise ConfigError(f'Specified source-interface {src_ifname} does not exist')
 
     if 'source_interface_is_bridge_member' in config:
         bridge_name = next(iter(config['source_interface_is_bridge_member']))
         raise ConfigError(f'Invalid source-interface "{src_ifname}". Interface '
                           f'is already a member of bridge "{bridge_name}"!')
 
     if 'source_interface_is_bond_member' in config:
         bond_name = next(iter(config['source_interface_is_bond_member']))
         raise ConfigError(f'Invalid source-interface "{src_ifname}". Interface '
                           f'is already a member of bond "{bond_name}"!')
 
     if 'is_source_interface' in config:
         tmp = config['is_source_interface']
         raise ConfigError(f'Can not use source-interface "{src_ifname}", it already ' \
                           f'belongs to interface "{tmp}"!')
 
 def verify_dhcpv6(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation of DHCPv6 options which are mutually exclusive.
     """
     if 'dhcpv6_options' in config:
         if {'parameters_only', 'temporary'} <= set(config['dhcpv6_options']):
             raise ConfigError('DHCPv6 temporary and parameters-only options '
                               'are mutually exclusive!')
 
         # It is not allowed to have duplicate SLA-IDs as those identify an
         # assigned IPv6 subnet from a delegated prefix
         for pd in (dict_search('dhcpv6_options.pd', config) or []):
             sla_ids = []
             interfaces = dict_search(f'dhcpv6_options.pd.{pd}.interface', config)
 
             if not interfaces:
                 raise ConfigError('DHCPv6-PD requires an interface where to assign '
                                   'the delegated prefix!')
 
             for count, interface in enumerate(interfaces):
                 if 'sla_id' in interfaces[interface]:
                     sla_ids.append(interfaces[interface]['sla_id'])
                 else:
                     sla_ids.append(str(count))
 
             # Check for duplicates
             duplicates = [x for n, x in enumerate(sla_ids) if x in sla_ids[:n]]
             if duplicates:
                 raise ConfigError('Site-Level Aggregation Identifier (SLA-ID) '
                                   'must be unique per prefix-delegation!')
 
 def verify_vlan_config(config):
     """
     Common helper function used by interface implementations to perform
     recurring validation of interface VLANs
     """
 
     # VLAN and Q-in-Q IDs are not allowed to overlap
     if 'vif' in config and 'vif_s' in config:
         duplicate = list(set(config['vif']) & set(config['vif_s']))
         if duplicate:
             raise ConfigError(f'Duplicate VLAN id "{duplicate[0]}" used for vif and vif-s interfaces!')
 
     parent_ifname = config['ifname']
     # 802.1q VLANs
     for vlan_id in config.get('vif', {}):
         vlan = config['vif'][vlan_id]
         vlan['ifname'] = f'{parent_ifname}.{vlan_id}'
 
         verify_dhcpv6(vlan)
         verify_address(vlan)
         verify_vrf(vlan)
         verify_mirror_redirect(vlan)
         verify_mtu_parent(vlan, config)
 
     # 802.1ad (Q-in-Q) VLANs
     for s_vlan_id in config.get('vif_s', {}):
         s_vlan = config['vif_s'][s_vlan_id]
         s_vlan['ifname'] = f'{parent_ifname}.{s_vlan_id}'
 
         verify_dhcpv6(s_vlan)
         verify_address(s_vlan)
         verify_vrf(s_vlan)
         verify_mirror_redirect(s_vlan)
         verify_mtu_parent(s_vlan, config)
 
         for c_vlan_id in s_vlan.get('vif_c', {}):
             c_vlan = s_vlan['vif_c'][c_vlan_id]
             c_vlan['ifname'] = f'{parent_ifname}.{s_vlan_id}.{c_vlan_id}'
 
             verify_dhcpv6(c_vlan)
             verify_address(c_vlan)
             verify_vrf(c_vlan)
             verify_mirror_redirect(c_vlan)
             verify_mtu_parent(c_vlan, config)
             verify_mtu_parent(c_vlan, s_vlan)
 
 
 def verify_diffie_hellman_length(file, min_keysize):
     """ Verify Diffie-Hellamn keypair length given via file. It must be greater
     then or equal to min_keysize """
     import os
     import re
     from vyos.utils.process import cmd
 
     try:
         keysize = str(min_keysize)
     except:
         return False
 
     if os.path.exists(file):
         out = cmd(f'openssl dhparam -inform PEM -in {file} -text')
         prog = re.compile('\d+\s+bit')
         if prog.search(out):
             bits = prog.search(out)[0].split()[0]
             if int(bits) >= int(min_keysize):
                 return True
 
     return False
 
 def verify_common_route_maps(config):
     """
     Common helper function used by routing protocol implementations to perform
     recurring validation if the specified route-map for either zebra to kernel
     installation exists (this is the top-level route_map key) or when a route
     is redistributed with a route-map that it exists!
     """
     # XXX: This function is called in combination with a previous call to:
     # tmp = conf.get_config_dict(['policy']) - see protocols_ospf.py as example.
     # We should NOT call this with the key_mangling option as this would rename
     # route-map hypens '-' to underscores '_' and one could no longer distinguish
     # what should have been the "proper" route-map name, as foo-bar and foo_bar
     # are two entire different route-map instances!
     for route_map in ['route-map', 'route_map']:
         if route_map not in config:
             continue
         tmp = config[route_map]
         # Check if the specified route-map exists, if not error out
         if dict_search(f'policy.route-map.{tmp}', config) == None:
             raise ConfigError(f'Specified route-map "{tmp}" does not exist!')
 
     if 'redistribute' in config:
         for protocol, protocol_config in config['redistribute'].items():
             if 'route_map' in protocol_config:
                 verify_route_map(protocol_config['route_map'], config)
 
 def verify_route_map(route_map_name, config):
     """
     Common helper function used by routing protocol implementations to perform
     recurring validation if a specified route-map exists!
     """
     # Check if the specified route-map exists, if not error out
     if dict_search(f'policy.route-map.{route_map_name}', config) == None:
         raise ConfigError(f'Specified route-map "{route_map_name}" does not exist!')
 
 def verify_prefix_list(prefix_list, config, version=''):
     """
     Common helper function used by routing protocol implementations to perform
     recurring validation if a specified prefix-list exists!
     """
     # Check if the specified prefix-list exists, if not error out
     if dict_search(f'policy.prefix-list{version}.{prefix_list}', config) == None:
         raise ConfigError(f'Specified prefix-list{version} "{prefix_list}" does not exist!')
 
 def verify_access_list(access_list, config, version=''):
     """
     Common helper function used by routing protocol implementations to perform
     recurring validation if a specified prefix-list exists!
     """
     # Check if the specified ACL exists, if not error out
     if dict_search(f'policy.access-list{version}.{access_list}', config) == None:
         raise ConfigError(f'Specified access-list{version} "{access_list}" does not exist!')
diff --git a/python/vyos/template.py b/python/vyos/template.py
index d1b3e8fa8..ffccae9a1 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -1,839 +1,840 @@
 # Copyright 2019-2023 VyOS maintainers and contributors <maintainers@vyos.io>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
 # version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
 import functools
 import os
 
 from jinja2 import Environment
 from jinja2 import FileSystemLoader
 from jinja2 import ChainableUndefined
 from vyos.defaults import directories
 from vyos.utils.dict import dict_search_args
 from vyos.utils.file import makedir
 from vyos.utils.permission import chmod
 from vyos.utils.permission import chown
 
 # Holds template filters registered via register_filter()
 _FILTERS = {}
 _TESTS = {}
 
 # reuse Environments with identical settings to improve performance
 @functools.lru_cache(maxsize=2)
 def _get_environment(location=None):
     if location is None:
         loc_loader=FileSystemLoader(directories["templates"])
     else:
         loc_loader=FileSystemLoader(location)
     env = Environment(
         # Don't check if template files were modified upon re-rendering
         auto_reload=False,
         # Cache up to this number of templates for quick re-rendering
         cache_size=100,
         loader=loc_loader,
         trim_blocks=True,
         undefined=ChainableUndefined,
         extensions=['jinja2.ext.loopcontrols']
     )
     env.filters.update(_FILTERS)
     env.tests.update(_TESTS)
     return env
 
 
 def register_filter(name, func=None):
     """Register a function to be available as filter in templates under given name.
 
     It can also be used as a decorator, see below in this module for examples.
 
     :raise RuntimeError:
         when trying to register a filter after a template has been rendered already
     :raise ValueError: when trying to register a name which was taken already
     """
     if func is None:
         return functools.partial(register_filter, name)
     if _get_environment.cache_info().currsize:
         raise RuntimeError(
             "Filters can only be registered before rendering the first template"
         )
     if name in _FILTERS:
         raise ValueError(f"A filter with name {name!r} was registered already")
     _FILTERS[name] = func
     return func
 
 def register_test(name, func=None):
     """Register a function to be available as test in templates under given name.
 
     It can also be used as a decorator, see below in this module for examples.
 
     :raise RuntimeError:
         when trying to register a test after a template has been rendered already
     :raise ValueError: when trying to register a name which was taken already
     """
     if func is None:
         return functools.partial(register_test, name)
     if _get_environment.cache_info().currsize:
         raise RuntimeError(
             "Tests can only be registered before rendering the first template"
             )
     if name in _TESTS:
         raise ValueError(f"A test with name {name!r} was registered already")
     _TESTS[name] = func
     return func
 
 
 def render_to_string(template, content, formater=None, location=None):
     """Render a template from the template directory, raise on any errors.
 
     :param template: the path to the template relative to the template folder
     :param content: the dictionary of variables to put into rendering context
     :param formater:
         if given, it has to be a callable the rendered string is passed through
 
     The parsed template files are cached, so rendering the same file multiple times
     does not cause as too much overhead.
     If used everywhere, it could be changed to load the template from Python
     environment variables from an importable Python module generated when the Debian
     package is build (recovering the load time and overhead caused by having the
     file out of the code).
     """
     template = _get_environment(location).get_template(template)
     rendered = template.render(content)
     if formater is not None:
         rendered = formater(rendered)
     return rendered
 
 
 def render(
     destination,
     template,
     content,
     formater=None,
     permission=None,
     user=None,
     group=None,
     location=None,
 ):
     """Render a template from the template directory to a file, raise on any errors.
 
     :param destination: path to the file to save the rendered template in
     :param permission: permission bitmask to set for the output file
     :param user: user to own the output file
     :param group: group to own the output file
 
     All other parameters are as for :func:`render_to_string`.
     """
     # Create the directory if it does not exist
     folder = os.path.dirname(destination)
     makedir(folder, user, group)
 
     # As we are opening the file with 'w', we are performing the rendering before
     # calling open() to not accidentally erase the file if rendering fails
     rendered = render_to_string(template, content, formater, location)
 
     # Write to file
     with open(destination, "w") as file:
         chmod(file.fileno(), permission)
         chown(file.fileno(), user, group)
         file.write(rendered)
 
 
 ##################################
 # Custom template filters follow #
 ##################################
 @register_filter('force_to_list')
 def force_to_list(value):
     """ Convert scalars to single-item lists and leave lists untouched """
     if isinstance(value, list):
         return value
     else:
         return [value]
 
 @register_filter('seconds_to_human')
 def seconds_to_human(seconds, separator=""):
     """ Convert seconds to human-readable values like 1d6h15m23s """
     from vyos.utils.convert import seconds_to_human
     return seconds_to_human(seconds, separator=separator)
 
 @register_filter('bytes_to_human')
 def bytes_to_human(bytes, initial_exponent=0, precision=2):
     """ Convert bytes to human-readable values like 1.44M """
     from vyos.utils.convert import bytes_to_human
     return bytes_to_human(bytes, initial_exponent=initial_exponent, precision=precision)
 
 @register_filter('human_to_bytes')
 def human_to_bytes(value):
     """ Convert a data amount with a unit suffix to bytes, like 2K to 2048 """
     from vyos.utils.convert import human_to_bytes
     return human_to_bytes(value)
 
 @register_filter('ip_from_cidr')
 def ip_from_cidr(prefix):
     """ Take an IPv4/IPv6 CIDR host and strip cidr mask.
     Example:
     192.0.2.1/24 -> 192.0.2.1, 2001:db8::1/64 -> 2001:db8::1
     """
     from ipaddress import ip_interface
     return str(ip_interface(prefix).ip)
 
 @register_filter('address_from_cidr')
 def address_from_cidr(prefix):
     """ Take an IPv4/IPv6 CIDR prefix and convert the network to an "address".
     Example:
     192.0.2.0/24 -> 192.0.2.0, 2001:db8::/48 -> 2001:db8::
     """
     from ipaddress import ip_network
     return str(ip_network(prefix).network_address)
 
 @register_filter('bracketize_ipv6')
 def bracketize_ipv6(address):
     """ Place a passed IPv6 address into [] brackets, do nothing for IPv4 """
     if is_ipv6(address):
         return f'[{address}]'
     return address
 
 @register_filter('dot_colon_to_dash')
 def dot_colon_to_dash(text):
     """ Replace dot and colon to dash for string
     Example:
     192.0.2.1 => 192-0-2-1, 2001:db8::1 => 2001-db8--1
     """
     text = text.replace(":", "-")
     text = text.replace(".", "-")
     return text
 
 @register_filter('generate_uuid4')
 def generate_uuid4(text):
     """ Generate random unique ID
     Example:
       % uuid4()
       UUID('958ddf6a-ef14-4e81-8cfb-afb12456d1c5')
     """
     from uuid import uuid4
     return uuid4()
 
 @register_filter('netmask_from_cidr')
 def netmask_from_cidr(prefix):
     """ Take CIDR prefix and convert the prefix length to a "subnet mask".
     Example:
       - 192.0.2.0/24 -> 255.255.255.0
       - 2001:db8::/48 -> ffff:ffff:ffff::
     """
     from ipaddress import ip_network
     return str(ip_network(prefix).netmask)
 
 @register_filter('netmask_from_ipv4')
 def netmask_from_ipv4(address):
     """ Take IP address and search all attached interface IP addresses for the
     given one. After address has been found, return the associated netmask.
 
     Example:
       - 172.18.201.10 -> 255.255.255.128
     """
     from netifaces import interfaces
     from netifaces import ifaddresses
     from netifaces import AF_INET
     for interface in interfaces():
         tmp = ifaddresses(interface)
         if AF_INET in tmp:
             for af_addr in tmp[AF_INET]:
                 if 'addr' in af_addr:
                     if af_addr['addr'] == address:
                         return af_addr['netmask']
 
     raise ValueError
 
 @register_filter('is_ip_network')
 def is_ip_network(addr):
     """ Take IP(v4/v6) address and validate if the passed argument is a network
     or a host address.
 
     Example:
       - 192.0.2.0          -> False
       - 192.0.2.10/24      -> False
       - 192.0.2.0/24       -> True
       - 2001:db8::         -> False
       - 2001:db8::100      -> False
       - 2001:db8::/48      -> True
       - 2001:db8:1000::/64 -> True
     """
     try:
         from ipaddress import ip_network
         # input variables must contain a / to indicate its CIDR notation
         if len(addr.split('/')) != 2:
             raise ValueError()
         ip_network(addr)
         return True
     except:
         return False
 
 @register_filter('network_from_ipv4')
 def network_from_ipv4(address):
     """ Take IP address and search all attached interface IP addresses for the
     given one. After address has been found, return the associated network
     address.
 
     Example:
       - 172.18.201.10 has mask 255.255.255.128 -> network is 172.18.201.0
     """
     netmask = netmask_from_ipv4(address)
     from ipaddress import ip_interface
     cidr_prefix = ip_interface(f'{address}/{netmask}').network
     return address_from_cidr(cidr_prefix)
 
 @register_filter('is_interface')
 def is_interface(interface):
     """ Check if parameter is a valid local interface name """
-    return os.path.exists(f'/sys/class/net/{interface}')
+    from vyos.utils.network import interface_exists
+    return interface_exists(interface)
 
 @register_filter('is_ip')
 def is_ip(addr):
     """ Check addr if it is an IPv4 or IPv6 address """
     return is_ipv4(addr) or is_ipv6(addr)
 
 @register_filter('is_ipv4')
 def is_ipv4(text):
     """ Filter IP address, return True on IPv4 address, False otherwise """
     from ipaddress import ip_interface
     try: return ip_interface(text).version == 4
     except: return False
 
 @register_filter('is_ipv6')
 def is_ipv6(text):
     """ Filter IP address, return True on IPv6 address, False otherwise """
     from ipaddress import ip_interface
     try: return ip_interface(text).version == 6
     except: return False
 
 @register_filter('first_host_address')
 def first_host_address(prefix):
     """ Return first usable (host) IP address from given prefix.
     Example:
       - 10.0.0.0/24 -> 10.0.0.1
       - 2001:db8::/64 -> 2001:db8::
     """
     from ipaddress import ip_interface
     tmp = ip_interface(prefix).network
     return str(tmp.network_address +1)
 
 @register_filter('last_host_address')
 def last_host_address(text):
     """ Return first usable IP address from given prefix.
     Example:
       - 10.0.0.0/24 -> 10.0.0.254
       - 2001:db8::/64 -> 2001:db8::ffff:ffff:ffff:ffff
     """
     from ipaddress import ip_interface
     from ipaddress import IPv4Network
     from ipaddress import IPv6Network
 
     addr = ip_interface(text)
     if addr.version == 4:
         return str(IPv4Network(addr).broadcast_address - 1)
 
     return str(IPv6Network(addr).broadcast_address)
 
 @register_filter('inc_ip')
 def inc_ip(address, increment):
     """ Increment given IP address by 'increment'
 
     Example (inc by 2):
       - 10.0.0.0/24 -> 10.0.0.2
       - 2001:db8::/64 -> 2001:db8::2
     """
     from ipaddress import ip_interface
     return str(ip_interface(address).ip + int(increment))
 
 @register_filter('dec_ip')
 def dec_ip(address, decrement):
     """ Decrement given IP address by 'decrement'
 
     Example (inc by 2):
       - 10.0.0.0/24 -> 10.0.0.2
       - 2001:db8::/64 -> 2001:db8::2
     """
     from ipaddress import ip_interface
     return str(ip_interface(address).ip - int(decrement))
 
 @register_filter('compare_netmask')
 def compare_netmask(netmask1, netmask2):
     """
     Compare two IP netmask if they have the exact same size.
 
     compare_netmask('10.0.0.0/8', '20.0.0.0/8') -> True
     compare_netmask('10.0.0.0/8', '20.0.0.0/16') -> False
     """
     from ipaddress import ip_network
     try:
         return ip_network(netmask1).netmask == ip_network(netmask2).netmask
     except:
         return False
 
 @register_filter('isc_static_route')
 def isc_static_route(subnet, router):
     # https://ercpe.de/blog/pushing-static-routes-with-isc-dhcp-server
     # Option format is:
     # <netmask>, <network-byte1>, <network-byte2>, <network-byte3>, <router-byte1>, <router-byte2>, <router-byte3>
     # where bytes with the value 0 are omitted.
     from ipaddress import ip_network
     net = ip_network(subnet)
     # add netmask
     string = str(net.prefixlen) + ','
     # add network bytes
     if net.prefixlen:
         width = net.prefixlen // 8
         if net.prefixlen % 8:
             width += 1
         string += ','.join(map(str,tuple(net.network_address.packed)[:width])) + ','
 
     # add router bytes
     string += ','.join(router.split('.'))
 
     return string
 
 @register_filter('is_file')
 def is_file(filename):
     if os.path.exists(filename):
         return os.path.isfile(filename)
     return False
 
 @register_filter('get_dhcp_router')
 def get_dhcp_router(interface):
     """ Static routes can point to a router received by a DHCP reply. This
     helper is used to get the current default router from the DHCP reply.
 
     Returns False of no router is found, returns the IP address as string if
     a router is found.
     """
     lease_file = directories['isc_dhclient_dir'] + f'/dhclient_{interface}.leases'
     if not os.path.exists(lease_file):
         return None
 
     from vyos.utils.file import read_file
     for line in read_file(lease_file).splitlines():
         if 'option routers' in line:
             (_, _, address) = line.split()
             return address.rstrip(';')
 
 @register_filter('natural_sort')
 def natural_sort(iterable):
     import re
     from jinja2.runtime import Undefined
 
     if isinstance(iterable, Undefined) or iterable is None:
         return list()
 
     def convert(text):
         return int(text) if text.isdigit() else text.lower()
     def alphanum_key(key):
         return [convert(c) for c in re.split('([0-9]+)', str(key))]
 
     return sorted(iterable, key=alphanum_key)
 
 @register_filter('get_ipv4')
 def get_ipv4(interface):
     """ Get interface IPv4 addresses"""
     from vyos.ifconfig import Interface
     return Interface(interface).get_addr_v4()
 
 @register_filter('get_ipv6')
 def get_ipv6(interface):
     """ Get interface IPv6 addresses"""
     from vyos.ifconfig import Interface
     return Interface(interface).get_addr_v6()
 
 @register_filter('get_ip')
 def get_ip(interface):
     """ Get interface IP addresses"""
     from vyos.ifconfig import Interface
     return Interface(interface).get_addr()
 
 def get_first_ike_dh_group(ike_group):
     if ike_group and 'proposal' in ike_group:
         for priority, proposal in ike_group['proposal'].items():
             if 'dh_group' in proposal:
                 return 'dh-group' + proposal['dh_group']
     return 'dh-group2' # Fallback on dh-group2
 
 @register_filter('get_esp_ike_cipher')
 def get_esp_ike_cipher(group_config, ike_group=None):
     pfs_lut = {
         'dh-group1'  : 'modp768',
         'dh-group2'  : 'modp1024',
         'dh-group5'  : 'modp1536',
         'dh-group14' : 'modp2048',
         'dh-group15' : 'modp3072',
         'dh-group16' : 'modp4096',
         'dh-group17' : 'modp6144',
         'dh-group18' : 'modp8192',
         'dh-group19' : 'ecp256',
         'dh-group20' : 'ecp384',
         'dh-group21' : 'ecp521',
         'dh-group22' : 'modp1024s160',
         'dh-group23' : 'modp2048s224',
         'dh-group24' : 'modp2048s256',
         'dh-group25' : 'ecp192',
         'dh-group26' : 'ecp224',
         'dh-group27' : 'ecp224bp',
         'dh-group28' : 'ecp256bp',
         'dh-group29' : 'ecp384bp',
         'dh-group30' : 'ecp512bp',
         'dh-group31' : 'curve25519',
         'dh-group32' : 'curve448'
     }
 
     ciphers = []
     if 'proposal' in group_config:
         for priority, proposal in group_config['proposal'].items():
             # both encryption and hash need to be specified for a proposal
             if not {'encryption', 'hash'} <= set(proposal):
                 continue
 
             tmp = '{encryption}-{hash}'.format(**proposal)
             if 'prf' in proposal:
                 tmp += '-' + proposal['prf']
             if 'dh_group' in proposal:
                 tmp += '-' + pfs_lut[ 'dh-group' +  proposal['dh_group'] ]
             elif 'pfs' in group_config and group_config['pfs'] != 'disable':
                 group = group_config['pfs']
                 if group_config['pfs'] == 'enable':
                     group = get_first_ike_dh_group(ike_group)
                 tmp += '-' + pfs_lut[group]
 
             ciphers.append(tmp)
     return ciphers
 
 @register_filter('get_uuid')
 def get_uuid(interface):
     """ Get interface IP addresses"""
     from uuid import uuid1
     return uuid1()
 
 openvpn_translate = {
     'des': 'des-cbc',
     '3des': 'des-ede3-cbc',
     'bf128': 'bf-cbc',
     'bf256': 'bf-cbc',
     'aes128gcm': 'aes-128-gcm',
     'aes128': 'aes-128-cbc',
     'aes192gcm': 'aes-192-gcm',
     'aes192': 'aes-192-cbc',
     'aes256gcm': 'aes-256-gcm',
     'aes256': 'aes-256-cbc'
 }
 
 @register_filter('openvpn_cipher')
 def get_openvpn_cipher(cipher):
     if cipher in openvpn_translate:
         return openvpn_translate[cipher].upper()
     return cipher.upper()
 
 @register_filter('openvpn_ncp_ciphers')
 def get_openvpn_ncp_ciphers(ciphers):
     out = []
     for cipher in ciphers:
         if cipher in openvpn_translate:
             out.append(openvpn_translate[cipher])
         else:
             out.append(cipher)
     return ':'.join(out).upper()
 
 @register_filter('snmp_auth_oid')
 def snmp_auth_oid(type):
     if type not in ['md5', 'sha', 'aes', 'des', 'none']:
         raise ValueError()
 
     OIDs = {
         'md5' : '.1.3.6.1.6.3.10.1.1.2',
         'sha' : '.1.3.6.1.6.3.10.1.1.3',
         'aes' : '.1.3.6.1.6.3.10.1.2.4',
         'des' : '.1.3.6.1.6.3.10.1.2.2',
         'none': '.1.3.6.1.6.3.10.1.2.1'
     }
     return OIDs[type]
 
 @register_filter('nft_action')
 def nft_action(vyos_action):
     if vyos_action == 'accept':
         return 'return'
     return vyos_action
 
 @register_filter('nft_rule')
 def nft_rule(rule_conf, fw_hook, fw_name, rule_id, ip_name='ip'):
     from vyos.firewall import parse_rule
     return parse_rule(rule_conf, fw_hook, fw_name, rule_id, ip_name)
 
 @register_filter('nft_default_rule')
 def nft_default_rule(fw_conf, fw_name, family):
     output = ['counter']
     default_action = fw_conf['default_action']
     #family = 'ipv6' if ipv6 else 'ipv4'
 
     if 'default_log' in fw_conf:
         action_suffix = default_action[:1].upper()
         output.append(f'log prefix "[{family}-{fw_name[:19]}-default-{action_suffix}]"')
 
     #output.append(nft_action(default_action))
     output.append(f'{default_action}')
     if 'default_jump_target' in fw_conf:
         target = fw_conf['default_jump_target']
         def_suffix = '6' if family == 'ipv6' else ''
         output.append(f'NAME{def_suffix}_{target}')
 
     output.append(f'comment "{fw_name} default-action {default_action}"')
     return " ".join(output)
 
 @register_filter('nft_state_policy')
 def nft_state_policy(conf, state):
     out = [f'ct state {state}']
 
     if 'log' in conf:
         log_state = state[:3].upper()
         log_action = (conf['action'] if 'action' in conf else 'accept')[:1].upper()
         out.append(f'log prefix "[STATE-POLICY-{log_state}-{log_action}]"')
 
         if 'log_level' in conf:
             log_level = conf['log_level']
             out.append(f'level {log_level}')
 
     out.append('counter')
 
     if 'action' in conf:
         out.append(conf['action'])
 
     return " ".join(out)
 
 @register_filter('nft_intra_zone_action')
 def nft_intra_zone_action(zone_conf, ipv6=False):
     if 'intra_zone_filtering' in zone_conf:
         intra_zone = zone_conf['intra_zone_filtering']
         fw_name = 'ipv6_name' if ipv6 else 'name'
         name_prefix = 'NAME6_' if ipv6 else 'NAME_'
 
         if 'action' in intra_zone:
             if intra_zone['action'] == 'accept':
                 return 'return'
             return intra_zone['action']
         elif dict_search_args(intra_zone, 'firewall', fw_name):
             name = dict_search_args(intra_zone, 'firewall', fw_name)
             return f'jump {name_prefix}{name}'
     return 'return'
 
 @register_filter('nft_nested_group')
 def nft_nested_group(out_list, includes, groups, key):
     if not vyos_defined(out_list):
         out_list = []
 
     def add_includes(name):
         if key in groups[name]:
             for item in groups[name][key]:
                 if item in out_list:
                     continue
                 out_list.append(item)
 
         if 'include' in groups[name]:
             for name_inc in groups[name]['include']:
                 add_includes(name_inc)
 
     for name in includes:
         add_includes(name)
     return out_list
 
 @register_filter('nat_rule')
 def nat_rule(rule_conf, rule_id, nat_type, ipv6=False):
     from vyos.nat import parse_nat_rule
     return parse_nat_rule(rule_conf, rule_id, nat_type, ipv6)
 
 @register_filter('nat_static_rule')
 def nat_static_rule(rule_conf, rule_id, nat_type):
     from vyos.nat import parse_nat_static_rule
     return parse_nat_static_rule(rule_conf, rule_id, nat_type)
 
 @register_filter('conntrack_rule')
 def conntrack_rule(rule_conf, rule_id, action, ipv6=False):
     ip_prefix = 'ip6' if ipv6 else 'ip'
     def_suffix = '6' if ipv6 else ''
     output = []
 
     if 'inbound_interface' in rule_conf:
         ifname = rule_conf['inbound_interface']
         if ifname != 'any':
             output.append(f'iifname {ifname}')
 
     if 'protocol' in rule_conf:
         if action != 'timeout':
             proto = rule_conf['protocol']
         else:
             for protocol, protocol_config in rule_conf['protocol'].items():
                 proto = protocol
         output.append(f'meta l4proto {proto}')
 
     tcp_flags = dict_search_args(rule_conf, 'tcp', 'flags')
     if tcp_flags and action != 'timeout':
         from vyos.firewall import parse_tcp_flags
         output.append(parse_tcp_flags(tcp_flags))
 
     for side in ['source', 'destination']:
         if side in rule_conf:
             side_conf = rule_conf[side]
             prefix = side[0]
 
             if 'address' in side_conf:
                 address = side_conf['address']
                 operator = ''
                 if address[0] == '!':
                     operator = '!='
                     address = address[1:]
                 output.append(f'{ip_prefix} {prefix}addr {operator} {address}')
 
             if 'port' in side_conf:
                 port = side_conf['port']
                 operator = ''
                 if port[0] == '!':
                     operator = '!='
                     port = port[1:]
                 output.append(f'th {prefix}port {operator} {port}')
 
             if 'group' in side_conf:
                 group = side_conf['group']
 
                 if 'address_group' in group:
                     group_name = group['address_group']
                     operator = ''
                     if group_name[0] == '!':
                         operator = '!='
                         group_name = group_name[1:]
                     output.append(f'{ip_prefix} {prefix}addr {operator} @A{def_suffix}_{group_name}')
                 # Generate firewall group domain-group
                 elif 'domain_group' in group:
                     group_name = group['domain_group']
                     operator = ''
                     if group_name[0] == '!':
                         operator = '!='
                         group_name = group_name[1:]
                     output.append(f'{ip_prefix} {prefix}addr {operator} @D_{group_name}')
                 elif 'network_group' in group:
                     group_name = group['network_group']
                     operator = ''
                     if group_name[0] == '!':
                         operator = '!='
                         group_name = group_name[1:]
                     output.append(f'{ip_prefix} {prefix}addr {operator} @N{def_suffix}_{group_name}')
                 if 'port_group' in group:
                     group_name = group['port_group']
 
                     if proto == 'tcp_udp':
                         proto = 'th'
 
                     operator = ''
                     if group_name[0] == '!':
                         operator = '!='
                         group_name = group_name[1:]
 
                     output.append(f'{proto} {prefix}port {operator} @P_{group_name}')
 
     if action == 'ignore':
         output.append('counter notrack')
         output.append(f'comment "ignore-{rule_id}"')
     else:
         output.append(f'counter ct timeout set ct-timeout-{rule_id}')
         output.append(f'comment "timeout-{rule_id}"')
 
     return " ".join(output)
 
 @register_filter('conntrack_ct_policy')
 def conntrack_ct_policy(protocol_conf):
     output = []
     for item in protocol_conf:
         item_value = protocol_conf[item]
         output.append(f'{item}: {item_value}')
 
     return ", ".join(output)
 
 @register_filter('range_to_regex')
 def range_to_regex(num_range):
     """Convert range of numbers or list of ranges
        to regex
 
        % range_to_regex('11-12')
        '(1[1-2])'
        % range_to_regex(['11-12', '14-15'])
        '(1[1-2]|1[4-5])'
     """
     from vyos.range_regex import range_to_regex
     if isinstance(num_range, list):
         data = []
         for entry in num_range:
             if '-' not in entry:
                 data.append(entry)
             else:
                 data.append(range_to_regex(entry))
         return f'({"|".join(data)})'
 
     if '-' not in num_range:
         return num_range
 
     regex = range_to_regex(num_range)
     return f'({regex})'
 
 @register_test('vyos_defined')
 def vyos_defined(value, test_value=None, var_type=None):
     """
     Jinja2 plugin to test if a variable is defined and not none - vyos_defined
     will test value if defined and is not none and return true or false.
 
     If test_value is supplied, the value must also pass == test_value to return true.
     If var_type is supplied, the value must also be of the specified class/type
 
     Examples:
     1. Test if var is defined and not none:
     {% if foo is vyos_defined %}
     ...
     {% endif %}
 
     2. Test if variable is defined, not none and has value "something"
     {% if bar is vyos_defined("something") %}
     ...
     {% endif %}
 
     Parameters
     ----------
     value : any
         Value to test from ansible
     test_value : any, optional
         Value to test in addition of defined and not none, by default None
     var_type : ['float', 'int', 'str', 'list', 'dict', 'tuple', 'bool'], optional
         Type or Class to test for
 
     Returns
     -------
     boolean
         True if variable matches criteria, False in other cases.
 
     Implementation inspired and re-used from https://github.com/aristanetworks/ansible-avd/
     """
 
     from jinja2 import Undefined
 
     if isinstance(value, Undefined) or value is None:
         # Invalid value - return false
         return False
     elif test_value is not None and value != test_value:
         # Valid value but not matching the optional argument
         return False
     elif str(var_type).lower() in ['float', 'int', 'str', 'list', 'dict', 'tuple', 'bool'] and str(var_type).lower() != type(value).__name__:
         # Invalid class - return false
         return False
     else:
         # Valid value and is matching optional argument if provided - return true
         return True
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index e967bee71..910a92a7c 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -1,489 +1,490 @@
 #!/usr/bin/env python3
 #
 # Copyright (C) 2021-2024 VyOS maintainers and contributors
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 or later as
 # published by the Free Software Foundation.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
 
 from hashlib import sha256
 from ipaddress import ip_address
 from ipaddress import ip_network
 from json import dumps as json_write
 
 from vyos.base import Warning
 from vyos.config import Config
 from vyos.configdict import dict_merge
 from vyos.configdict import node_changed
 from vyos.configdict import is_node_changed
 from vyos.configverify import verify_vrf
 from vyos.ifconfig import Interface
 from vyos.utils.file import write_file
 from vyos.utils.process import call
 from vyos.utils.process import cmd
 from vyos.utils.process import run
+from vyos.utils.network import interface_exists
 from vyos.template import bracketize_ipv6
 from vyos.template import inc_ip
 from vyos.template import is_ipv4
 from vyos.template import is_ipv6
 from vyos.template import render
 from vyos.xml_ref import default_value
 from vyos import ConfigError
 from vyos import airbag
 airbag.enable()
 
 config_containers = '/etc/containers/containers.conf'
 config_registry = '/etc/containers/registries.conf'
 config_storage = '/etc/containers/storage.conf'
 systemd_unit_path = '/run/systemd/system'
 
 def _cmd(command):
     if os.path.exists('/tmp/vyos.container.debug'):
         print(command)
     return cmd(command)
 
 def network_exists(name):
     # Check explicit name for network, returns True if network exists
     c = _cmd(f'podman network ls --quiet --filter name=^{name}$')
     return bool(c)
 
 # Common functions
 def get_config(config=None):
     if config:
         conf = config
     else:
         conf = Config()
 
     base = ['container']
     container = conf.get_config_dict(base, key_mangling=('-', '_'),
                                      no_tag_node_value_mangle=True,
                                      get_first_key=True,
                                      with_recursive_defaults=True)
 
     for name in container.get('name', []):
         # T5047: Any container related configuration changed? We only
         # wan't to restart the required containers and not all of them ...
         tmp = is_node_changed(conf, base + ['name', name])
         if tmp:
             if 'container_restart' not in container:
                 container['container_restart'] = [name]
             else:
                 container['container_restart'].append(name)
 
     # registry is a tagNode with default values - merge the list from
     # default_values['registry'] into the tagNode variables
     if 'registry' not in container:
         container.update({'registry' : {}})
         default_values = default_value(base + ['registry'])
         for registry in default_values:
             tmp = {registry : {}}
             container['registry'] = dict_merge(tmp, container['registry'])
 
     # Delete container network, delete containers
     tmp = node_changed(conf, base + ['network'])
     if tmp: container.update({'network_remove' : tmp})
 
     tmp = node_changed(conf, base + ['name'])
     if tmp: container.update({'container_remove' : tmp})
 
     return container
 
 def verify(container):
     # bail out early - looks like removal from running config
     if not container:
         return None
 
     # Add new container
     if 'name' in container:
         for name, container_config in container['name'].items():
             # Container image is a mandatory option
             if 'image' not in container_config:
                 raise ConfigError(f'Container image for "{name}" is mandatory!')
 
             # Check if requested container image exists locally. If it does not
             # exist locally - inform the user. This is required as there is a
             # shared container image storage accross all VyOS images. A user can
             # delete a container image from the system, boot into another version
             # of VyOS and then it would fail to boot. This is to prevent any
             # configuration error when container images are deleted from the
             # global storage. A per image local storage would be a super waste
             # of diskspace as there will be a full copy (up tu several GB/image)
             # on upgrade. This is the "cheapest" and fastest solution in terms
             # of image upgrade and deletion.
             image = container_config['image']
             if run(f'podman image exists {image}') != 0:
                 Warning(f'Image "{image}" used in container "{name}" does not exist '\
                         f'locally. Please use "add container image {image}" to add it '\
                         f'to the system! Container "{name}" will not be started!')
 
             if 'network' in container_config:
                 if len(container_config['network']) > 1:
                     raise ConfigError(f'Only one network can be specified for container "{name}"!')
 
                 # Check if the specified container network exists
                 network_name = list(container_config['network'])[0]
                 if network_name not in container.get('network', {}):
                     raise ConfigError(f'Container network "{network_name}" does not exist!')
 
                 if 'address' in container_config['network'][network_name]:
                     cnt_ipv4 = 0
                     cnt_ipv6 = 0
                     for address in container_config['network'][network_name]['address']:
                         network = None
                         if is_ipv4(address):
                             try:
                                 network = [x for x in container['network'][network_name]['prefix'] if is_ipv4(x)][0]
                                 cnt_ipv4 += 1
                             except:
                                 raise ConfigError(f'Network "{network_name}" does not contain an IPv4 prefix!')
                         elif is_ipv6(address):
                             try:
                                 network = [x for x in container['network'][network_name]['prefix'] if is_ipv6(x)][0]
                                 cnt_ipv6 += 1
                             except:
                                 raise ConfigError(f'Network "{network_name}" does not contain an IPv6 prefix!')
 
                         # Specified container IP address must belong to network prefix
                         if ip_address(address) not in ip_network(network):
                             raise ConfigError(f'Used container address "{address}" not in network "{network}"!')
 
                         # We can not use the first IP address of a network prefix as this is used by podman
                         if ip_address(address) == ip_network(network)[1]:
                             raise ConfigError(f'IP address "{address}" can not be used for a container, '\
                                               'reserved for the container engine!')
 
                     if cnt_ipv4 > 1 or cnt_ipv6 > 1:
                         raise ConfigError(f'Only one IP address per address family can be used for '\
                                           f'container "{name}". {cnt_ipv4} IPv4 and {cnt_ipv6} IPv6 address(es)!')
 
             if 'device' in container_config:
                 for dev, dev_config in container_config['device'].items():
                     if 'source' not in dev_config:
                         raise ConfigError(f'Device "{dev}" has no source path configured!')
 
                     if 'destination' not in dev_config:
                         raise ConfigError(f'Device "{dev}" has no destination path configured!')
 
                     source = dev_config['source']
                     if not os.path.exists(source):
                         raise ConfigError(f'Device "{dev}" source path "{source}" does not exist!')
 
             if 'environment' in container_config:
                 for var, cfg in container_config['environment'].items():
                     if 'value' not in cfg:
                         raise ConfigError(f'Environment variable {var} has no value assigned!')
 
             if 'label' in container_config:
                 for var, cfg in container_config['label'].items():
                     if 'value' not in cfg:
                         raise ConfigError(f'Label variable {var} has no value assigned!')
 
             if 'volume' in container_config:
                 for volume, volume_config in container_config['volume'].items():
                     if 'source' not in volume_config:
                         raise ConfigError(f'Volume "{volume}" has no source path configured!')
 
                     if 'destination' not in volume_config:
                         raise ConfigError(f'Volume "{volume}" has no destination path configured!')
 
                     source = volume_config['source']
                     if not os.path.exists(source):
                         raise ConfigError(f'Volume "{volume}" source path "{source}" does not exist!')
 
             if 'port' in container_config:
                 for tmp in container_config['port']:
                     if not {'source', 'destination'} <= set(container_config['port'][tmp]):
                         raise ConfigError(f'Both "source" and "destination" must be specified for a port mapping!')
 
             # If 'allow-host-networks' or 'network' not set.
             if 'allow_host_networks' not in container_config and 'network' not in container_config:
                 raise ConfigError(f'Must either set "network" or "allow-host-networks" for container "{name}"!')
 
             # Can not set both allow-host-networks and network at the same time
             if {'allow_host_networks', 'network'} <= set(container_config):
                 raise ConfigError(f'"allow-host-networks" and "network" for "{name}" cannot be both configured at the same time!')
 
             # gid cannot be set without uid
             if 'gid' in container_config and 'uid' not in container_config:
                 raise ConfigError(f'Cannot set "gid" without "uid" for container')
 
     # Add new network
     if 'network' in container:
         for network, network_config in container['network'].items():
             v4_prefix = 0
             v6_prefix = 0
             # If ipv4-prefix not defined for user-defined network
             if 'prefix' not in network_config:
                 raise ConfigError(f'prefix for network "{network}" must be defined!')
 
             for prefix in network_config['prefix']:
                 if is_ipv4(prefix): v4_prefix += 1
                 elif is_ipv6(prefix): v6_prefix += 1
 
             if v4_prefix > 1:
                 raise ConfigError(f'Only one IPv4 prefix can be defined for network "{network}"!')
             if v6_prefix > 1:
                 raise ConfigError(f'Only one IPv6 prefix can be defined for network "{network}"!')
 
             # Verify VRF exists
             verify_vrf(network_config)
 
     # A network attached to a container can not be deleted
     if {'network_remove', 'name'} <= set(container):
         for network in container['network_remove']:
             for c, c_config in container['name'].items():
                 if 'network' in c_config and network in c_config['network']:
                     raise ConfigError(f'Can not remove network "{network}", used by container "{c}"!')
 
     if 'registry' in container:
         for registry, registry_config in container['registry'].items():
             if 'authentication' not in registry_config:
                 continue
             if not {'username', 'password'} <= set(registry_config['authentication']):
                 raise ConfigError('Container registry requires both username and password to be set!')
 
     return None
 
 def generate_run_arguments(name, container_config):
     image = container_config['image']
     memory = container_config['memory']
     shared_memory = container_config['shared_memory']
     restart = container_config['restart']
 
     # Add capability options. Should be in uppercase
     cap_add = ''
     if 'cap_add' in container_config:
         for c in container_config['cap_add']:
             c = c.upper()
             c = c.replace('-', '_')
             cap_add += f' --cap-add={c}'
 
     # Add a host device to the container /dev/x:/dev/x
     device = ''
     if 'device' in container_config:
         for dev, dev_config in container_config['device'].items():
             source_dev = dev_config['source']
             dest_dev = dev_config['destination']
             device += f' --device={source_dev}:{dest_dev}'
 
     # Check/set environment options "-e foo=bar"
     env_opt = ''
     if 'environment' in container_config:
         for k, v in container_config['environment'].items():
             env_opt += f" --env \"{k}={v['value']}\""
 
     # Check/set label options "--label foo=bar"
     label = ''
     if 'label' in container_config:
         for k, v in container_config['label'].items():
             label += f" --label \"{k}={v['value']}\""
 
     hostname = ''
     if 'host_name' in container_config:
         hostname = container_config['host_name']
         hostname = f'--hostname {hostname}'
 
     # Publish ports
     port = ''
     if 'port' in container_config:
         protocol = ''
         for portmap in container_config['port']:
             protocol = container_config['port'][portmap]['protocol']
             sport = container_config['port'][portmap]['source']
             dport = container_config['port'][portmap]['destination']
             listen_addresses = container_config['port'][portmap].get('listen_address', [])
 
             # If listen_addresses is not empty, include them in the publish command
             if listen_addresses:
                 for listen_address in listen_addresses:
                     port += f' --publish {bracketize_ipv6(listen_address)}:{sport}:{dport}/{protocol}'
             else:
                 # If listen_addresses is empty, just include the standard publish command
                 port += f' --publish {sport}:{dport}/{protocol}'
 
     # Set uid and gid
     uid = ''
     if 'uid' in container_config:
         uid = container_config['uid']
         if 'gid' in container_config:
             uid += ':' + container_config['gid']
         uid = f'--user {uid}'
 
     # Bind volume
     volume = ''
     if 'volume' in container_config:
         for vol, vol_config in container_config['volume'].items():
             svol = vol_config['source']
             dvol = vol_config['destination']
             mode = vol_config['mode']
             prop = vol_config['propagation']
             volume += f' --volume {svol}:{dvol}:{mode},{prop}'
 
     container_base_cmd = f'--detach --interactive --tty --replace {cap_add} ' \
                          f'--memory {memory}m --shm-size {shared_memory}m --memory-swap 0 --restart {restart} ' \
                          f'--name {name} {hostname} {device} {port} {volume} {env_opt} {label} {uid}'
 
     entrypoint = ''
     if 'entrypoint' in container_config:
         # it needs to be json-formatted with single quote on the outside
         entrypoint = json_write(container_config['entrypoint'].split()).replace('"', "&quot;")
         entrypoint = f'--entrypoint &apos;{entrypoint}&apos;'
 
     hostname = ''
     if 'host_name' in container_config:
         hostname = container_config['host_name']
         hostname = f'--hostname {hostname}'
 
     command = ''
     if 'command' in container_config:
         command = container_config['command'].strip()
 
     command_arguments = ''
     if 'arguments' in container_config:
         command_arguments = container_config['arguments'].strip()
 
     if 'allow_host_networks' in container_config:
         return f'{container_base_cmd} --net host {entrypoint} {image} {command} {command_arguments}'.strip()
 
     ip_param = ''
     networks = ",".join(container_config['network'])
     for network in container_config['network']:
         if 'address' not in container_config['network'][network]:
             continue
         for address in container_config['network'][network]['address']:
             if is_ipv6(address):
                 ip_param += f' --ip6 {address}'
             else:
                 ip_param += f' --ip {address}'
 
     return f'{container_base_cmd} --no-healthcheck --net {networks} {ip_param} {entrypoint} {image} {command} {command_arguments}'.strip()
 
 def generate(container):
     # bail out early - looks like removal from running config
     if not container:
         for file in [config_containers, config_registry, config_storage]:
             if os.path.exists(file):
                 os.unlink(file)
         return None
 
     if 'network' in container:
         for network, network_config in container['network'].items():
             tmp = {
                 'name': network,
                 'id' : sha256(f'{network}'.encode()).hexdigest(),
                 'driver': 'bridge',
                 'network_interface': f'pod-{network}',
                 'subnets': [],
                 'ipv6_enabled': False,
                 'internal': False,
                 'dns_enabled': True,
                 'ipam_options': {
                     'driver': 'host-local'
                 }
             }
             for prefix in network_config['prefix']:
                 net = {'subnet' : prefix, 'gateway' : inc_ip(prefix, 1)}
                 tmp['subnets'].append(net)
 
                 if is_ipv6(prefix):
                     tmp['ipv6_enabled'] = True
 
             write_file(f'/etc/containers/networks/{network}.json', json_write(tmp, indent=2))
 
     render(config_containers, 'container/containers.conf.j2', container)
     render(config_registry, 'container/registries.conf.j2', container)
     render(config_storage, 'container/storage.conf.j2', container)
 
     if 'name' in container:
         for name, container_config in container['name'].items():
             if 'disable' in container_config:
                 continue
 
             file_path = os.path.join(systemd_unit_path, f'vyos-container-{name}.service')
             run_args = generate_run_arguments(name, container_config)
             render(file_path, 'container/systemd-unit.j2', {'name': name, 'run_args': run_args,},
                    formater=lambda _: _.replace("&quot;", '"').replace("&apos;", "'"))
 
     return None
 
 def apply(container):
     # Delete old containers if needed. We can't delete running container
     # Option "--force" allows to delete containers with any status
     if 'container_remove' in container:
         for name in container['container_remove']:
             file_path = os.path.join(systemd_unit_path, f'vyos-container-{name}.service')
             call(f'systemctl stop vyos-container-{name}.service')
             if os.path.exists(file_path):
                 os.unlink(file_path)
 
     call('systemctl daemon-reload')
 
     # Delete old networks if needed
     if 'network_remove' in container:
         for network in container['network_remove']:
             call(f'podman network rm {network} >/dev/null 2>&1')
 
     # Add container
     disabled_new = False
     if 'name' in container:
         for name, container_config in container['name'].items():
             image = container_config['image']
 
             if run(f'podman image exists {image}') != 0:
                 # container image does not exist locally - user already got
                 # informed by a WARNING in verfiy() - bail out early
                 continue
 
             if 'disable' in container_config:
                 # check if there is a container by that name running
                 tmp = _cmd('podman ps -a --format "{{.Names}}"')
                 if name in tmp:
                     file_path = os.path.join(systemd_unit_path, f'vyos-container-{name}.service')
                     call(f'systemctl stop vyos-container-{name}.service')
                     if os.path.exists(file_path):
                         disabled_new = True
                         os.unlink(file_path)
                 continue
 
             if 'container_restart' in container and name in container['container_restart']:
                 cmd(f'systemctl restart vyos-container-{name}.service')
 
     if disabled_new:
         call('systemctl daemon-reload')
 
     # Start network and assign it to given VRF if requested. this can only be done
     # after the containers got started as the podman network interface will
     # only be enabled by the first container and yet I do not know how to enable
     # the network interface in advance
     if 'network' in container:
         for network, network_config in container['network'].items():
             network_name = f'pod-{network}'
             # T5147: Networks are started only as soon as there is a consumer.
             # If only a network is created in the first place, no need to assign
             # it to a VRF as there's no consumer, yet.
-            if os.path.exists(f'/sys/class/net/{network_name}'):
+            if interface_exists(network_name):
                 tmp = Interface(network_name)
                 tmp.add_ipv6_eui64_address('fe80::/64')
                 tmp.set_vrf(network_config.get('vrf', ''))
 
     return None
 
 if __name__ == '__main__':
     try:
         c = get_config()
         verify(c)
         generate(c)
         apply(c)
     except ConfigError as e:
         print(e)
         exit(1)
diff --git a/src/conf_mode/qos.py b/src/conf_mode/qos.py
index 4a0b4d0c5..2b4fcc1bf 100755
--- a/src/conf_mode/qos.py
+++ b/src/conf_mode/qos.py
@@ -1,243 +1,244 @@
 #!/usr/bin/env python3
 #
 # Copyright (C) 2023-2024 VyOS maintainers and contributors
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 or later as
 # published by the Free Software Foundation.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 import os
 
 from sys import exit
 from netifaces import interfaces
 
 from vyos.base import Warning
 from vyos.config import Config
 from vyos.configdep import set_dependents, call_dependents
 from vyos.configdict import dict_merge
 from vyos.ifconfig import Section
 from vyos.qos import CAKE
 from vyos.qos import DropTail
 from vyos.qos import FairQueue
 from vyos.qos import FQCodel
 from vyos.qos import Limiter
 from vyos.qos import NetEm
 from vyos.qos import Priority
 from vyos.qos import RandomDetect
 from vyos.qos import RateLimiter
 from vyos.qos import RoundRobin
 from vyos.qos import TrafficShaper
 from vyos.qos import TrafficShaperHFSC
-from vyos.utils.process import run
 from vyos.utils.dict import dict_search_recursive
+from vyos.utils.network import interface_exists
+from vyos.utils.process import run
 from vyos import ConfigError
 from vyos import airbag
 airbag.enable()
 
 map_vyops_tc = {
     'cake'             : CAKE,
     'drop_tail'        : DropTail,
     'fair_queue'       : FairQueue,
     'fq_codel'         : FQCodel,
     'limiter'          : Limiter,
     'network_emulator' : NetEm,
     'priority_queue'   : Priority,
     'random_detect'    : RandomDetect,
     'rate_control'     : RateLimiter,
     'round_robin'      : RoundRobin,
     'shaper'           : TrafficShaper,
     'shaper_hfsc'      : TrafficShaperHFSC,
 }
 
 def get_shaper(qos, interface_config, direction):
     policy_name = interface_config[direction]
     # An interface might have a QoS configuration, search the used
     # configuration referenced by this. Path will hold the dict element
     # referenced by the config, as this will be of sort:
     #
     # ['policy', 'drop_tail', 'foo-dtail'] <- we are only interested in
     # drop_tail as the policy/shaper type
     _, path = next(dict_search_recursive(qos, policy_name))
     shaper_type = path[1]
     shaper_config = qos['policy'][shaper_type][policy_name]
 
     return (map_vyops_tc[shaper_type], shaper_config)
 
 def get_config(config=None):
     if config:
         conf = config
     else:
         conf = Config()
     base = ['qos']
     if not conf.exists(base):
         return None
 
     qos = conf.get_config_dict(base, key_mangling=('-', '_'),
                                get_first_key=True,
                                no_tag_node_value_mangle=True)
 
     for ifname in interfaces():
         if_node = Section.get_config_path(ifname)
 
         if not if_node:
             continue
 
         path = f'interfaces {if_node}'
         if conf.exists(f'{path} mirror') or conf.exists(f'{path} redirect'):
             type_node = path.split(" ")[1] # return only interface type node
             set_dependents(type_node, conf, ifname.split(".")[0])
 
     for policy in qos.get('policy', []):
         if policy in ['random_detect']:
             for rd_name in list(qos['policy'][policy]):
                 # There are eight precedence levels - ensure all are present
                 # to be filled later down with the appropriate default values
                 default_precedence = {'precedence' : { '0' : {}, '1' : {}, '2' : {}, '3' : {},
                                                        '4' : {}, '5' : {}, '6' : {}, '7' : {} }}
                 qos['policy']['random_detect'][rd_name] = dict_merge(
                     default_precedence, qos['policy']['random_detect'][rd_name])
 
     qos = conf.merge_defaults(qos, recursive=True)
 
     for policy in qos.get('policy', []):
         for p_name, p_config in qos['policy'][policy].items():
             if 'precedence' in p_config:
                 # precedence settings are a bit more complex as they are
                 # calculated under specific circumstances:
                 for precedence in p_config['precedence']:
                     max_thr = int(qos['policy'][policy][p_name]['precedence'][precedence]['maximum_threshold'])
                     if 'minimum_threshold' not in qos['policy'][policy][p_name]['precedence'][precedence]:
                         qos['policy'][policy][p_name]['precedence'][precedence]['minimum_threshold'] = str(
                             int((9 + int(precedence)) * max_thr) // 18);
 
                     if 'queue_limit' not in qos['policy'][policy][p_name]['precedence'][precedence]:
                         qos['policy'][policy][p_name]['precedence'][precedence]['queue_limit'] = \
                             str(int(4 * max_thr))
 
     return qos
 
 def verify(qos):
     if not qos or 'interface' not in qos:
         return None
 
     # network policy emulator
     # reorder rerquires delay to be set
     if 'policy' in qos:
         for policy_type in qos['policy']:
             for policy, policy_config in qos['policy'][policy_type].items():
                 # a policy with it's given name is only allowed to exist once
                 # on the system. This is because an interface selects a policy
                 # for ingress/egress traffic, and thus there can only be one
                 # policy with a given name.
                 #
                 # We check if the policy name occurs more then once - error out
                 # if this is true
                 counter = 0
                 for _, path in dict_search_recursive(qos['policy'], policy):
                     counter += 1
                     if counter > 1:
                         raise ConfigError(f'Conflicting policy name "{policy}", already in use!')
 
                 if 'class' in policy_config:
                     for cls, cls_config in policy_config['class'].items():
                         # bandwidth is not mandatory for priority-queue - that is why this is on the exception list
                         if 'bandwidth' not in cls_config and policy_type not in ['priority_queue', 'round_robin', 'shaper_hfsc']:
                             raise ConfigError(f'Bandwidth must be defined for policy "{policy}" class "{cls}"!')
                     if 'match' in cls_config:
                         for match, match_config in cls_config['match'].items():
                             if {'ip', 'ipv6'} <= set(match_config):
                                  raise ConfigError(f'Can not use both IPv6 and IPv4 in one match ({match})!')
 
                 if policy_type in ['random_detect']:
                     if 'precedence' in policy_config:
                         for precedence, precedence_config in policy_config['precedence'].items():
                             max_tr = int(precedence_config['maximum_threshold'])
                             if {'maximum_threshold', 'minimum_threshold'} <= set(precedence_config):
                                 min_tr = int(precedence_config['minimum_threshold'])
                                 if min_tr >= max_tr:
                                     raise ConfigError(f'Policy "{policy}" uses min-threshold "{min_tr}" >= max-threshold "{max_tr}"!')
 
                             if {'maximum_threshold', 'queue_limit'} <= set(precedence_config):
                                 queue_lim = int(precedence_config['queue_limit'])
                                 if queue_lim < max_tr:
                                     raise ConfigError(f'Policy "{policy}" uses queue-limit "{queue_lim}" < max-threshold "{max_tr}"!')
                 if policy_type in ['priority_queue']:
                     if 'default' not in policy_config:
                         raise ConfigError(f'Policy {policy} misses "default" class!')
                 if 'default' in policy_config:
                     if 'bandwidth' not in policy_config['default'] and policy_type not in ['priority_queue', 'round_robin', 'shaper_hfsc']:
                         raise ConfigError('Bandwidth not defined for default traffic!')
 
     # we should check interface ingress/egress configuration after verifying that
     # the policy name is used only once - this makes the logic easier!
     for interface, interface_config in qos['interface'].items():
         for direction in ['egress', 'ingress']:
             # bail out early if shaper for given direction is not used at all
             if direction not in interface_config:
                 continue
 
             policy_name = interface_config[direction]
             if 'policy' not in qos or list(dict_search_recursive(qos['policy'], policy_name)) == []:
                 raise ConfigError(f'Selected QoS policy "{policy_name}" does not exist!')
 
             shaper_type, shaper_config = get_shaper(qos, interface_config, direction)
             tmp = shaper_type(interface).get_direction()
             if direction not in tmp:
                 raise ConfigError(f'Selected QoS policy on interface "{interface}" only supports "{tmp}"!')
 
     return None
 
 def generate(qos):
     if not qos or 'interface' not in qos:
         return None
 
     return None
 
 def apply(qos):
     # Always delete "old" shapers first
     for interface in interfaces():
         # Ignore errors (may have no qdisc)
         run(f'tc qdisc del dev {interface} parent ffff:')
         run(f'tc qdisc del dev {interface} root')
 
     call_dependents()
 
     if not qos or 'interface' not in qos:
         return None
 
     for interface, interface_config in qos['interface'].items():
-        if not os.path.exists(f'/sys/class/net/{interface}'):
+        if not interface_exists(interface):
             # When shaper is bound to a dialup (e.g. PPPoE) interface it is
             # possible that it is yet not availbale when to QoS code runs.
             # Skip the configuration and inform the user
             Warning(f'Interface "{interface}" does not exist!')
             continue
 
         for direction in ['egress', 'ingress']:
             # bail out early if shaper for given direction is not used at all
             if direction not in interface_config:
                 continue
 
             shaper_type, shaper_config = get_shaper(qos, interface_config, direction)
             tmp = shaper_type(interface)
             tmp.update(shaper_config, direction)
 
     return None
 
 if __name__ == '__main__':
     try:
         c = get_config()
         verify(c)
         generate(c)
         apply(c)
     except ConfigError as e:
         print(e)
         exit(1)
diff --git a/src/tests/test_template.py b/src/tests/test_template.py
index aba97015e..dbb86b40b 100644
--- a/src/tests/test_template.py
+++ b/src/tests/test_template.py
@@ -1,194 +1,194 @@
 #!/usr/bin/env python3
 #
-# Copyright (C) 2020-2023 VyOS maintainers and contributors
+# Copyright (C) 2020-2024 VyOS maintainers and contributors
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 or later as
 # published by the Free Software Foundation.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import os
 import vyos.template
 
+from vyos.utils.network import interface_exists
 from ipaddress import ip_network
 from unittest import TestCase
 
 class TestVyOSTemplate(TestCase):
     def setUp(self):
         pass
 
     def test_is_interface(self):
         for interface in ['lo', 'eth0']:
-            if os.path.exists(f'/sys/class/net/{interface}'):
+            if interface_exists(interface):
                 self.assertTrue(vyos.template.is_interface(interface))
             else:
                 self.assertFalse(vyos.template.is_interface(interface))
         self.assertFalse(vyos.template.is_interface('non-existent'))
 
     def test_is_ip(self):
         self.assertTrue(vyos.template.is_ip('192.0.2.1'))
         self.assertTrue(vyos.template.is_ip('2001:db8::1'))
         self.assertFalse(vyos.template.is_ip('VyOS'))
 
     def test_is_ipv4(self):
         self.assertTrue(vyos.template.is_ipv4('192.0.2.1'))
         self.assertTrue(vyos.template.is_ipv4('192.0.2.0/24'))
         self.assertTrue(vyos.template.is_ipv4('192.0.2.1/32'))
 
         self.assertFalse(vyos.template.is_ipv4('2001:db8::1'))
         self.assertFalse(vyos.template.is_ipv4('2001:db8::/64'))
         self.assertFalse(vyos.template.is_ipv4('VyOS'))
 
     def test_is_ipv6(self):
         self.assertTrue(vyos.template.is_ipv6('2001:db8::1'))
         self.assertTrue(vyos.template.is_ipv6('2001:db8::/64'))
         self.assertTrue(vyos.template.is_ipv6('2001:db8::1/64'))
 
         self.assertFalse(vyos.template.is_ipv6('192.0.2.1'))
         self.assertFalse(vyos.template.is_ipv6('192.0.2.0/24'))
         self.assertFalse(vyos.template.is_ipv6('192.0.2.1/32'))
         self.assertFalse(vyos.template.is_ipv6('VyOS'))
 
     def test_address_from_cidr(self):
         self.assertEqual(vyos.template.address_from_cidr('192.0.2.0/24'),  '192.0.2.0')
         self.assertEqual(vyos.template.address_from_cidr('2001:db8::/48'), '2001:db8::')
 
         with self.assertRaises(ValueError):
             # ValueError: 192.0.2.1/24 has host bits set
             self.assertEqual(vyos.template.address_from_cidr('192.0.2.1/24'),  '192.0.2.1')
 
         with self.assertRaises(ValueError):
             # ValueError: 2001:db8::1/48 has host bits set
             self.assertEqual(vyos.template.address_from_cidr('2001:db8::1/48'), '2001:db8::1')
 
         network_v4 = '192.0.2.0/26'
         self.assertEqual(vyos.template.address_from_cidr(network_v4), str(ip_network(network_v4).network_address))
 
     def test_netmask_from_cidr(self):
         self.assertEqual(vyos.template.netmask_from_cidr('192.0.2.0/24'),  '255.255.255.0')
         self.assertEqual(vyos.template.netmask_from_cidr('192.0.2.128/25'),  '255.255.255.128')
         self.assertEqual(vyos.template.netmask_from_cidr('2001:db8::/48'), 'ffff:ffff:ffff::')
 
         with self.assertRaises(ValueError):
             # ValueError: 192.0.2.1/24 has host bits set
             self.assertEqual(vyos.template.netmask_from_cidr('192.0.2.1/24'),  '255.255.255.0')
 
         with self.assertRaises(ValueError):
             # ValueError: 2001:db8:1:/64 has host bits set
             self.assertEqual(vyos.template.netmask_from_cidr('2001:db8:1:/64'), 'ffff:ffff:ffff:ffff::')
 
         network_v4 = '192.0.2.0/26'
         self.assertEqual(vyos.template.netmask_from_cidr(network_v4), str(ip_network(network_v4).netmask))
 
     def test_first_host_address(self):
         self.assertEqual(vyos.template.first_host_address('10.0.0.0/24'), '10.0.0.1')
         self.assertEqual(vyos.template.first_host_address('10.0.0.10/24'), '10.0.0.1')
         self.assertEqual(vyos.template.first_host_address('10.0.0.255/24'), '10.0.0.1')
         self.assertEqual(vyos.template.first_host_address('10.0.0.128/25'), '10.0.0.129')
         self.assertEqual(vyos.template.first_host_address('2001:db8::/64'), '2001:db8::1')
         self.assertEqual(vyos.template.first_host_address('2001:db8::1000/64'), '2001:db8::1')
         self.assertEqual(vyos.template.first_host_address('2001:db8::ffff:ffff:ffff:ffff/64'), '2001:db8::1')
 
     def test_last_host_address(self):
         self.assertEqual(vyos.template.last_host_address('10.0.0.0/24'), '10.0.0.254')
         self.assertEqual(vyos.template.last_host_address('10.0.0.128/25'), '10.0.0.254')
         self.assertEqual(vyos.template.last_host_address('2001:db8::/64'), '2001:db8::ffff:ffff:ffff:ffff')
 
     def test_increment_ip(self):
         self.assertEqual(vyos.template.inc_ip('10.0.0.0/24', '2'), '10.0.0.2')
         self.assertEqual(vyos.template.inc_ip('10.0.0.0', '2'), '10.0.0.2')
         self.assertEqual(vyos.template.inc_ip('10.0.0.0', '10'), '10.0.0.10')
         self.assertEqual(vyos.template.inc_ip('2001:db8::/64', '2'), '2001:db8::2')
         self.assertEqual(vyos.template.inc_ip('2001:db8::', '10'), '2001:db8::a')
 
     def test_decrement_ip(self):
         self.assertEqual(vyos.template.dec_ip('10.0.0.100/24', '1'), '10.0.0.99')
         self.assertEqual(vyos.template.dec_ip('10.0.0.90', '10'), '10.0.0.80')
         self.assertEqual(vyos.template.dec_ip('2001:db8::b/64', '10'), '2001:db8::1')
         self.assertEqual(vyos.template.dec_ip('2001:db8::f', '5'), '2001:db8::a')
 
     def test_is_network(self):
         self.assertFalse(vyos.template.is_ip_network('192.0.2.0'))
         self.assertFalse(vyos.template.is_ip_network('192.0.2.1/24'))
         self.assertTrue(vyos.template.is_ip_network('192.0.2.0/24'))
 
         self.assertFalse(vyos.template.is_ip_network('2001:db8::'))
         self.assertFalse(vyos.template.is_ip_network('2001:db8::ffff'))
         self.assertTrue(vyos.template.is_ip_network('2001:db8::/48'))
         self.assertTrue(vyos.template.is_ip_network('2001:db8:1000::/64'))
 
     def test_is_network(self):
         self.assertTrue(vyos.template.compare_netmask('10.0.0.0/8', '20.0.0.0/8'))
         self.assertTrue(vyos.template.compare_netmask('10.0.0.0/16', '20.0.0.0/16'))
         self.assertFalse(vyos.template.compare_netmask('10.0.0.0/8', '20.0.0.0/16'))
         self.assertFalse(vyos.template.compare_netmask('10.0.0.1', '20.0.0.0/16'))
 
         self.assertTrue(vyos.template.compare_netmask('2001:db8:1000::/48', '2001:db8:2000::/48'))
         self.assertTrue(vyos.template.compare_netmask('2001:db8:1000::/64', '2001:db8:2000::/64'))
         self.assertFalse(vyos.template.compare_netmask('2001:db8:1000::/48', '2001:db8:2000::/64'))
 
     def test_cipher_to_string(self):
         ESP_DEFAULT = 'aes256gcm128-sha256-ecp256,aes128ccm64-sha256-ecp256'
         IKEv2_DEFAULT = 'aes256gcm128-sha256-ecp256,aes128ccm128-md5_128-modp1024'
 
         data = {
             'esp_group': {
                 'ESP_DEFAULT': {
                     'compression': 'disable',
                     'lifetime': '3600',
                     'mode': 'tunnel',
                     'pfs': 'dh-group19',
                     'proposal': {
                         '10': {
                             'encryption': 'aes256gcm128',
                             'hash': 'sha256',
                         },
                         '20': {
                             'encryption': 'aes128ccm64',
                             'hash': 'sha256',
                         }
                     }
                 }
             },
             'ike_group': {
                 'IKEv2_DEFAULT': {
                     'close_action': 'none',
                     'dead_peer_detection': {
                         'action': 'hold',
                         'interval': '30',
                         'timeout': '120'
                     },
                     'ikev2_reauth': 'no',
                     'key_exchange': 'ikev2',
                     'lifetime': '10800',
                     'mobike': 'disable',
                     'proposal': {
                         '10': {
                             'dh_group': '19',
                             'encryption': 'aes256gcm128',
                             'hash': 'sha256'
                         },
                         '20': {
                             'dh_group': '2',
                             'encryption': 'aes128ccm128',
                             'hash': 'md5_128'
                         },
                     }
                 }
             },
         }
 
         for group_name, group_config in data['esp_group'].items():
             ciphers = vyos.template.get_esp_ike_cipher(group_config)
             self.assertIn(ESP_DEFAULT, ','.join(ciphers))
 
         for group_name, group_config in data['ike_group'].items():
             ciphers = vyos.template.get_esp_ike_cipher(group_config)
             self.assertIn(IKEv2_DEFAULT, ','.join(ciphers))