diff --git a/python/vyos/frr.py b/python/vyos/frr.py
index 3bab64301..df6849472 100644
--- a/python/vyos/frr.py
+++ b/python/vyos/frr.py
@@ -1,470 +1,518 @@
 # Copyright 2020 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/>.
 
 r"""
 A Library for interracting with the FRR daemon suite.
 It supports simple configuration manipulation and loading using the official tools
 supplied with FRR (vtysh and frr-reload)
 
 All configuration management and manipulation is done using strings and regex.
 
 
 Example Usage
 #####
 
 # Reading configuration from frr:
 ```
 >>> original_config = get_configuration()
 >>> repr(original_config)
 '!\nfrr version 7.3.1\nfrr defaults traditional\nhostname debian\n......
 ```
 
 
 # Modify a configuration section:
 ```
 >>> new_bgp_section = 'router bgp 65000\n neighbor 192.0.2.1 remote-as 65000\n'
 >>> modified_config = replace_section(original_config, new_bgp_section, replace_re=r'router bgp \d+')
 >>> repr(modified_config)
 '............router bgp 65000\n neighbor 192.0.2.1 remote-as 65000\n...........'
 ```
 
 Remove a configuration section:
 ```
 >>> modified_config = remove_section(original_config, r'router ospf')
 ```
 
 Test the new configuration:
 ```
 >>> try:
 >>>     mark_configuration(modified configuration)
 >>> except ConfigurationNotValid as e:
 >>>     print('resulting configuration is not valid')
 >>>     sys.exit(1)
 ```
 
 Apply the new configuration:
 ```
 >>> try:
 >>>     replace_configuration(modified_config)
 >>> except CommitError as e:
 >>>     print('Exception while commiting the supplied configuration')
 >>>     print(e)
 >>>     exit(1)
 ```
 """
 
 import tempfile
 import re
 from vyos import util
+from vyos.util import chown
+from vyos.util import cmd
 import logging
+from logging.handlers import SysLogHandler
+import os
 LOG = logging.getLogger(__name__)
 
+DEBUG = os.path.exists('/tmp/vyos.frr.debug')
+if DEBUG:
+    LOG.setLevel(logging.DEBUG)
+    ch = SysLogHandler(address='/dev/log')
+    ch2 = logging.StreamHandler()
+    LOG.addHandler(ch)
+    LOG.addHandler(ch2)
 
 _frr_daemons = ['zebra', 'bgpd', 'fabricd', 'isisd', 'ospf6d', 'ospfd', 'pbrd',
                 'pimd', 'ripd', 'ripngd', 'sharpd', 'staticd', 'vrrpd', 'ldpd']
 
 path_vtysh = '/usr/bin/vtysh'
 path_frr_reload = '/usr/lib/frr/frr-reload.py'
+path_config = '/run/frr'
 
 
 class FrrError(Exception):
     pass
 
 
 class ConfigurationNotValid(FrrError):
     """
     The configuratioin supplied to vtysh is not valid
     """
     pass
 
 
 class CommitError(FrrError):
     """
     Commiting the supplied configuration failed to commit by a unknown reason
     see commit error and/or run mark_configuration on the specified configuration
     to se error generated
 
     used by: reload_configuration()
     """
     pass
 
 
 class ConfigSectionNotFound(FrrError):
     """
     Removal of configuration failed because it is not existing in the supplied configuration
     """
     pass
 
 
 def get_configuration(daemon=None, marked=False):
     """ Get current running FRR configuration
     daemon:  Collect only configuration for the specified FRR daemon,
              supplying daemon=None retrieves the complete configuration
     marked:  Mark the configuration with "end" tags
 
     return:  string containing the running configuration from frr
 
     """
     if daemon and daemon not in _frr_daemons:
         raise ValueError(f'The specified daemon type is not supported {repr(daemon)}')
 
     cmd = f"{path_vtysh} -c 'show run'"
     if daemon:
         cmd += f' -d {daemon}'
 
     output, code = util.popen(cmd, stderr=util.STDOUT)
     if code:
         raise OSError(code, output)
 
     config = output.replace('\r', '')
     # Remove first header lines from FRR config
     config = config.split("\n", 3)[-1]
     # Mark the configuration with end tags
     if marked:
         config = mark_configuration(config)
 
     return config
 
 
 def mark_configuration(config):
     """ Add end marks and Test the configuration for syntax faults
     If the configuration is valid a marked version of the configuration is returned,
     or else it failes with a ConfigurationNotValid Exception
 
     config:  The configuration string to mark/test
     return:  The marked configuration from FRR
     """
     output, code = util.popen(f"{path_vtysh} -m -f -", stderr=util.STDOUT, input=config)
 
     if code == 2:
         raise ConfigurationNotValid(str(output))
     elif code:
         raise OSError(code, output)
 
     config = output.replace('\r', '')
     return config
 
 
 def reload_configuration(config, daemon=None):
     """ Execute frr-reload with the new configuration
     This will try to reapply the supplied configuration inside FRR.
     The configuration needs to be a complete configuration from the integrated config or
     from a daemon.
 
     config:  The configuration to apply
     daemon:  Apply the conigutaion to the specified FRR daemon,
              supplying daemon=None applies to the integrated configuration
     return:  None
     """
     if daemon and daemon not in _frr_daemons:
         raise ValueError(f'The specified daemon type is not supported {repr(daemon)}')
 
     f = tempfile.NamedTemporaryFile('w')
     f.write(config)
     f.flush()
 
+    LOG.debug(f'reload_configuration: Reloading config using temporary file: {f.name}')
     cmd = f'{path_frr_reload} --reload'
     if daemon:
         cmd += f' --daemon {daemon}'
+
+    if DEBUG:
+        cmd += f' --debug --stdout'
+
     cmd += f' {f.name}'
 
+    LOG.debug(f'reload_configuration: Executing command against frr-reload: "{cmd}"')
     output, code = util.popen(cmd, stderr=util.STDOUT)
     f.close()
+    for i, e in enumerate(output.split('\n')):
+        LOG.debug(f'frr-reload output: {i:3} {e}')
     if code == 1:
-        raise CommitError(f'Configuration FRR failed while commiting code: {repr(output)}')
+        raise CommitError('FRR configuration failed while running commit. Please ' \
+                          'enable debugging to examine logs.\n\n\n' \
+                          'To enable debugging run: "touch /tmp/vyos.frr.debug" ' \
+                          'and "sudo systemctl stop vyos-configd"')
     elif code:
         raise OSError(code, output)
 
     return output
 
 
+def save_configuration():
+    """Save FRR configuration to /run/frr/config/frr.conf
+       It save configuration on each commit. T3217
+    """
+
+    cmd(f'{path_vtysh} -n -w')
+
+    return
+
+
 def execute(command):
     """ Run commands inside vtysh
     command:  str containing commands to execute inside a vtysh session
     """
     if not isinstance(command, str):
         raise ValueError(f'command needs to be a string: {repr(command)}')
 
     cmd = f"{path_vtysh} -c '{command}'"
 
     output, code = util.popen(cmd, stderr=util.STDOUT)
     if code:
         raise OSError(code, output)
 
     config = output.replace('\r', '')
     return config
 
 
 def configure(lines, daemon=False):
     """ run commands inside config mode vtysh
     lines:  list or str conaining commands to execute inside a configure session
             only one command executed on each configure()
             Executing commands inside a subcontext uses the list to describe the context
             ex: ['router bgp 6500', 'neighbor 192.0.2.1 remote-as 65000']
     return: None
     """
     if isinstance(lines, str):
         lines = [lines]
     elif not isinstance(lines, list):
         raise ValueError('lines needs to be string or list of commands')
 
     if daemon and daemon not in _frr_daemons:
         raise ValueError(f'The specified daemon type is not supported {repr(daemon)}')
 
     cmd = f'{path_vtysh}'
     if daemon:
         cmd += f' -d {daemon}'
 
     cmd += " -c 'configure terminal'"
     for x in lines:
         cmd += f" -c '{x}'"
 
     output, code = util.popen(cmd, stderr=util.STDOUT)
     if code == 1:
         raise ConfigurationNotValid(f'Configuration FRR failed: {repr(output)}')
     elif code:
         raise OSError(code, output)
 
     config = output.replace('\r', '')
     return config
 
 
 def _replace_section(config, replacement, replace_re, before_re):
     r"""Replace a section of FRR config
     config:      full original configuration
     replacement: replacement configuration section
     replace_re:  The regex to replace
                  example: ^router bgp \d+$.?*^!$
                  this will replace everything between ^router bgp X$ and ^!$
     before_re:   When replace_re is not existant, the config will be added before this tag
                  example: ^line vty$
 
     return:      modified configuration as a text file
     """
     # DEPRECATED, this is replaced by a new implementation
     # Check if block is configured, remove the existing instance else add a new one
     if re.findall(replace_re, config, flags=re.MULTILINE | re.DOTALL):
         # Section is in the configration, replace it
         return re.sub(replace_re, replacement, config, count=1,
                       flags=re.MULTILINE | re.DOTALL)
     if before_re:
         if not re.findall(before_re, config, flags=re.MULTILINE | re.DOTALL):
             raise ConfigSectionNotFound(f"Config section {before_re} not found in config")
 
         # If no section is in the configuration, add it before the line vty line
         return re.sub(before_re, rf'{replacement}\n\g<1>', config, count=1,
                       flags=re.MULTILINE | re.DOTALL)
 
     raise ConfigSectionNotFound(f"Config section {replacement} not found in config")
 
 
 def replace_section(config, replacement, from_re, to_re=r'!', before_re=r'line vty'):
     r"""Replace a section of FRR config
     config:      full original configuration
     replacement: replacement configuration section
     from_re:     Regex for the start of section matching
                  example: 'router bgp \d+'
     to_re:       Regex for stop of section matching
                  default: '!'
                  example: '!'  or  'end'
     before_re:   When from_re/to_re  does not return a match, the config will
                  be added before this tag
                  default: ^line vty$
 
     startline and endline tags will be automatically added to the resulting from_re/to_re and before_re regex'es
     """
     # DEPRECATED, this is replaced by a new implementation
     return _replace_section(config, replacement, replace_re=rf'^{from_re}$.*?^{to_re}$', before_re=rf'^({before_re})$')
 
 
 def remove_section(config, from_re, to_re='!'):
     # DEPRECATED, this is replaced by a new implementation
     return _replace_section(config, '', replace_re=rf'^{from_re}$.*?^{to_re}$', before_re=None)
 
 
 def _find_first_block(config, start_pattern, stop_pattern, start_at=0):
     '''Find start and stop line numbers for a config block
     config:        (list) A list conaining the configuration that is searched
     start_pattern: (raw-str) The pattern searched for a a start of block tag
     stop_pattern:  (raw-str) The pattern searched for to signify the end of the block
     start_at:      (int) The index to start searching at in the <config>
 
     Returns:
         None: No complete block could be found
         set(int, int): A complete block found between the line numbers returned in the set
 
     The object <config> is searched from the start for the regex <start_pattern> until the first match is found.
     On a successful match it continues the search for the regex <stop_pattern> until it is found.
     After a successful run a set is returned containing the start and stop line numbers.
     '''
     LOG.debug(f'_find_first_block: find start={repr(start_pattern)} stop={repr(stop_pattern)} start_at={start_at}')
     _start = None
     for i, element in enumerate(config[start_at:], start=start_at):
         # LOG.debug(f'_find_first_block: running line {i:3} "{element}"')
         if not _start:
             if not re.match(start_pattern, element):
                 LOG.debug(f'_find_first_block: no match     {i:3} "{element}"')
                 continue
             _start = i
             LOG.debug(f'_find_first_block: Found start  {i:3} "{element}"')
             continue
 
         if not re.match(stop_pattern, element):
             LOG.debug(f'_find_first_block: no match     {i:3} "{element}"')
             continue
 
         LOG.debug(f'_find_first_block: Found stop   {i:3} "{element}"')
         return (_start, i)
 
     LOG.debug('_find_first_block: exit start={repr(start_pattern)} stop={repr(stop_pattern)} start_at={start_at}')
     return None
 
 
 def _find_first_element(config, pattern, start_at=0):
     '''Find the first element that matches the current pattern in config
     config:        (list) A list containing the configuration that is searched
     start_pattern: (raw-str) The pattern searched for
     start_at:      (int) The index to start searching at in the <config>
 
     return:   Line index of the line containing the searched pattern
 
     TODO: for now it returns -1 on a no-match because 0 also returns as False
     TODO: that means that we can not use False matching to tell if its
     '''
     LOG.debug(f'_find_first_element: find start="{pattern}" start_at={start_at}')
     for i, element in enumerate(config[start_at:], start=0):
         if re.match(pattern + '$', element):
             LOG.debug(f'_find_first_element: Found stop {i:3} "{element}"')
             return i
         LOG.debug(f'_find_first_element: no match   {i:3} "{element}"')
     LOG.debug(f'_find_first_element: Did not find any match, exiting')
     return -1
 
 
 def _find_elements(config, pattern, start_at=0):
     '''Find all instances of pattern and return a list containing all element indexes
     config:        (list) A list containing the configuration that is searched
     start_pattern: (raw-str) The pattern searched for
     start_at:      (int) The index to start searching at in the <config>
 
     return:    A list of line indexes containing the searched pattern
     TODO: refactor this to return a generator instead
     '''
     return [i for i, element in enumerate(config[start_at:], start=0) if re.match(pattern + '$', element)]
 
 
 class FRRConfig:
     '''Main FRR Configuration manipulation object
     Using this object the user could load, manipulate and commit the configuration to FRR
     '''
     def __init__(self, config=[]):
         self.imported_config = ''
 
         if isinstance(config, list):
             self.config = config.copy()
             self.original_config = config.copy()
         elif isinstance(config, str):
             self.config = config.split('\n')
             self.original_config = self.config.copy()
         else:
             raise ValueError(
                 'The config element needs to be a string or list type object')
 
+        if config:
+            LOG.debug(f'__init__: frr library initiated with initial config')
+            for i, e in enumerate(self.config):
+                LOG.debug(f'__init__: initial              {i:3} {e}')
+
     def load_configuration(self, daemon=None):
         '''Load the running configuration from FRR into the config object
         daemon: str with name of the FRR Daemon to load configuration from or
                 None to load the consolidated config
 
         Using this overwrites the current loaded config objects and replaces the original loaded config
         '''
         self.imported_config = get_configuration(daemon=daemon)
-        LOG.debug(f'load_configuration: Configuration loaded from FRR: {self.imported_config}')
+        if daemon:
+            LOG.debug(f'load_configuration: Configuration loaded from FRR daemon {daemon}')
+        else:
+            LOG.debug(f'load_configuration: Configuration loaded from FRR integrated config')
+
         self.original_config = self.imported_config.split('\n')
         self.config = self.original_config.copy()
+
+        for i, e in enumerate(self.imported_config.split('\n')):
+            LOG.debug(f'load_configuration:  loaded    {i:3} {e}')
         return
 
     def test_configuration(self):
         '''Test the current configuration against FRR
         This will exception if FRR failes to load the current configuration object
         '''
         LOG.debug('test_configation: Testing configuration')
         mark_configuration('\n'.join(self.config))
 
     def commit_configuration(self, daemon=None):
         '''Commit the current configuration to FRR
            daemon: str with name of the FRR daemon to commit to or
                    None to use the consolidated config
         '''
         LOG.debug('commit_configuration:  Commiting configuration')
+        for i, e in enumerate(self.config):
+            LOG.debug(f'commit_configuration: new_config {i:3} {e}')
         reload_configuration('\n'.join(self.config), daemon=daemon)
 
     def modify_section(self, start_pattern, replacement=[], stop_pattern=r'\S+', remove_stop_mark=False, count=0):
         if isinstance(replacement, str):
             replacement = replacement.split('\n')
         elif not isinstance(replacement, list):
             return ValueError("The replacement element needs to be a string or list type object")
         LOG.debug(f'modify_section: starting search for {repr(start_pattern)} until {repr(stop_pattern)}')
 
         _count = 0
         _next_start = 0
         while True:
             if count and count <= _count:
                 # Break out of the loop after specified amount of matches
                 LOG.debug(f'modify_section: reached limit ({_count}), exiting loop at line {_next_start}')
                 break
             # While searching, always assume that the user wants to search for the exact pattern he entered
             # To be more specific the user needs a override, eg. a "pattern.*"
             _w = _find_first_block(
                 self.config, start_pattern+'$', stop_pattern, start_at=_next_start)
             if not _w:
                 # Reached the end, no more elements to remove
                 LOG.debug(f'modify_section: No more config sections found, exiting')
                 break
             start_element, end_element = _w
             LOG.debug(f'modify_section:   found match between {start_element} and {end_element}')
             for i, e in enumerate(self.config[start_element:end_element+1 if remove_stop_mark else end_element],
                                   start=start_element):
                 LOG.debug(f'modify_section:   remove       {i:3} {e}')
             del self.config[start_element:end_element +
                             1 if remove_stop_mark else end_element]
             if replacement:
                 # Append the replacement config at the current position
                 for i, e in enumerate(replacement, start=start_element):
                     LOG.debug(f'modify_section:   add          {i:3} {e}')
                 self.config[start_element:start_element] = replacement
             _count += 1
             _next_start = start_element + len(replacement)
 
         return _count
 
     def add_before(self, before_pattern, addition):
         '''Add config block before this element in the configuration'''
         if isinstance(addition, str):
             addition = addition.split('\n')
         elif not isinstance(addition, list):
             return ValueError("The replacement element needs to be a string or list type object")
 
         start = _find_first_element(self.config, before_pattern)
         if start < 0:
             return False
-
+        for i, e in enumerate(addition, start=start):
+            LOG.debug(f'add_before:   add          {i:3} {e}')
         self.config[start:start] = addition
         return True
 
     def __str__(self):
         return '\n'.join(self.config)
 
     def __repr__(self):
         return f'frr({repr(str(self))})'
diff --git a/src/conf_mode/protocols_rip.py b/src/conf_mode/protocols_rip.py
index 8ddd705f2..f36abbf90 100755
--- a/src/conf_mode/protocols_rip.py
+++ b/src/conf_mode/protocols_rip.py
@@ -1,320 +1,321 @@
 #!/usr/bin/env python3
 #
 # Copyright (C) 2020 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 vyos import ConfigError
 from vyos.config import Config
 from vyos.util import call
 from vyos.template import render
 
 from vyos import airbag
 airbag.enable()
 
 config_file = r'/tmp/ripd.frr'
 
 def get_config(config=None):
     if config:
         conf = config
     else:
         conf = Config()
     base = ['protocols', 'rip']
     rip_conf = {
         'rip_conf'          : False,
         'default_distance'  : [],
         'default_originate' : False,
         'old_rip'  : {
             'default_metric'  : [],
             'distribute'      : {},
             'neighbors'       : {},
             'networks'        : {},
             'net_distance'    : {},
             'passive_iface'   : {},
             'redist'          : {},
             'route'           : {},
             'ifaces'          : {},
             'timer_garbage'   : 120,
             'timer_timeout'   : 180,
             'timer_update'    : 30
         },
         'rip'  : {
             'default_metric'   : None,
             'distribute'       : {},
             'neighbors'        : {},
             'networks'         : {},
             'net_distance'     : {},
             'passive_iface'    : {},
             'redist'           : {},
             'route'            : {},
             'ifaces'           : {},
             'timer_garbage'    : 120,
             'timer_timeout'    : 180,
             'timer_update'     : 30
         }
     }
 
     if not (conf.exists(base) or conf.exists_effective(base)):
         return None
 
     if conf.exists(base):
         rip_conf['rip_conf'] = True
 
     conf.set_level(base)
 
     # Get default distance
     if conf.exists_effective('default-distance'):
         rip_conf['old_default_distance'] = conf.return_effective_value('default-distance')
 
     if conf.exists('default-distance'):
         rip_conf['default_distance'] = conf.return_value('default-distance')
 
     # Get default information originate (originate default route)
     if conf.exists_effective('default-information originate'):
         rip_conf['old_default_originate'] = True
 
     if conf.exists('default-information originate'):
         rip_conf['default_originate'] = True
 
     # Get default-metric
     if conf.exists_effective('default-metric'):
         rip_conf['old_rip']['default_metric'] = conf.return_effective_value('default-metric')
 
     if conf.exists('default-metric'):
         rip_conf['rip']['default_metric'] = conf.return_value('default-metric')
 
     # Get distribute list interface old_rip
     for dist_iface in conf.list_effective_nodes('distribute-list interface'):
         # Set level 'distribute-list interface ethX'
         conf.set_level(base + ['distribute-list', 'interface', dist_iface])
         rip_conf['rip']['distribute'].update({
         dist_iface : {
             'iface_access_list_in': conf.return_effective_value('access-list in'.format(dist_iface)),
             'iface_access_list_out': conf.return_effective_value('access-list out'.format(dist_iface)),
             'iface_prefix_list_in': conf.return_effective_value('prefix-list in'.format(dist_iface)),
             'iface_prefix_list_out': conf.return_effective_value('prefix-list out'.format(dist_iface))
             }
         })
 
         # Access-list in old_rip
         if conf.exists_effective('access-list in'.format(dist_iface)):
             rip_conf['old_rip']['iface_access_list_in'] = conf.return_effective_value('access-list in'.format(dist_iface))
         # Access-list out old_rip
         if conf.exists_effective('access-list out'.format(dist_iface)):
             rip_conf['old_rip']['iface_access_list_out'] = conf.return_effective_value('access-list out'.format(dist_iface))
         # Prefix-list in old_rip
         if conf.exists_effective('prefix-list in'.format(dist_iface)):
             rip_conf['old_rip']['iface_prefix_list_in'] = conf.return_effective_value('prefix-list in'.format(dist_iface))
         # Prefix-list out old_rip
         if conf.exists_effective('prefix-list out'.format(dist_iface)):
             rip_conf['old_rip']['iface_prefix_list_out'] = conf.return_effective_value('prefix-list out'.format(dist_iface))
 
     conf.set_level(base)
 
-    # Get distribute list interface 
+    # Get distribute list interface
     for dist_iface in conf.list_nodes('distribute-list interface'):
         # Set level 'distribute-list interface ethX'
         conf.set_level(base + ['distribute-list', 'interface', dist_iface])
         rip_conf['rip']['distribute'].update({
         dist_iface : {
             'iface_access_list_in': conf.return_value('access-list in'.format(dist_iface)),
             'iface_access_list_out': conf.return_value('access-list out'.format(dist_iface)),
             'iface_prefix_list_in': conf.return_value('prefix-list in'.format(dist_iface)),
             'iface_prefix_list_out': conf.return_value('prefix-list out'.format(dist_iface))
             }
         })
 
         # Access-list in
         if conf.exists('access-list in'.format(dist_iface)):
             rip_conf['rip']['iface_access_list_in'] = conf.return_value('access-list in'.format(dist_iface))
         # Access-list out
         if conf.exists('access-list out'.format(dist_iface)):
             rip_conf['rip']['iface_access_list_out'] = conf.return_value('access-list out'.format(dist_iface))
         # Prefix-list in
         if conf.exists('prefix-list in'.format(dist_iface)):
             rip_conf['rip']['iface_prefix_list_in'] = conf.return_value('prefix-list in'.format(dist_iface))
         # Prefix-list out
         if conf.exists('prefix-list out'.format(dist_iface)):
             rip_conf['rip']['iface_prefix_list_out'] = conf.return_value('prefix-list out'.format(dist_iface))
 
     conf.set_level(base + ['distribute-list'])
 
     # Get distribute list, access-list in
     if conf.exists_effective('access-list in'):
         rip_conf['old_rip']['dist_acl_in'] = conf.return_effective_value('access-list in')
 
     if conf.exists('access-list in'):
         rip_conf['rip']['dist_acl_in'] = conf.return_value('access-list in')
 
     # Get distribute list, access-list out
     if conf.exists_effective('access-list out'):
         rip_conf['old_rip']['dist_acl_out'] = conf.return_effective_value('access-list out')
 
     if conf.exists('access-list out'):
         rip_conf['rip']['dist_acl_out'] = conf.return_value('access-list out')
 
     # Get ditstribute list, prefix-list in
     if conf.exists_effective('prefix-list in'):
         rip_conf['old_rip']['dist_prfx_in'] = conf.return_effective_value('prefix-list in')
 
     if conf.exists('prefix-list in'):
         rip_conf['rip']['dist_prfx_in'] = conf.return_value('prefix-list in')
 
     # Get distribute list, prefix-list out
     if conf.exists_effective('prefix-list out'):
         rip_conf['old_rip']['dist_prfx_out'] = conf.return_effective_value('prefix-list out')
 
     if conf.exists('prefix-list out'):
         rip_conf['rip']['dist_prfx_out'] = conf.return_value('prefix-list out')
 
     conf.set_level(base)
 
     # Get network Interfaces
     if conf.exists_effective('interface'):
         rip_conf['old_rip']['ifaces'] = conf.return_effective_values('interface')
 
     if conf.exists('interface'):
         rip_conf['rip']['ifaces'] = conf.return_values('interface')
 
     # Get neighbors
     if conf.exists_effective('neighbor'):
         rip_conf['old_rip']['neighbors'] = conf.return_effective_values('neighbor')
 
     if conf.exists('neighbor'):
         rip_conf['rip']['neighbors'] = conf.return_values('neighbor')
 
     # Get networks
     if conf.exists_effective('network'):
         rip_conf['old_rip']['networks'] = conf.return_effective_values('network')
 
     if conf.exists('network'):
         rip_conf['rip']['networks'] = conf.return_values('network')
 
     # Get network-distance old_rip
     for net_dist in conf.list_effective_nodes('network-distance'):
         rip_conf['old_rip']['net_distance'].update({
             net_dist : {
                 'access_list' : conf.return_effective_value('network-distance {0} access-list'.format(net_dist)),
                 'distance' : conf.return_effective_value('network-distance {0} distance'.format(net_dist)),
             }
         })
 
     # Get network-distance
     for net_dist in conf.list_nodes('network-distance'):
         rip_conf['rip']['net_distance'].update({
             net_dist : {
                 'access_list' : conf.return_value('network-distance {0} access-list'.format(net_dist)),
                 'distance' : conf.return_value('network-distance {0} distance'.format(net_dist)),
             }
         })
 
     # Get passive-interface
     if conf.exists_effective('passive-interface'):
         rip_conf['old_rip']['passive_iface'] = conf.return_effective_values('passive-interface')
 
     if conf.exists('passive-interface'):
         rip_conf['rip']['passive_iface'] = conf.return_values('passive-interface')
 
     # Get redistribute for old_rip
     for protocol in conf.list_effective_nodes('redistribute'):
         rip_conf['old_rip']['redist'].update({
             protocol : {
                 'metric' : conf.return_effective_value('redistribute {0} metric'.format(protocol)),
                 'route_map' : conf.return_effective_value('redistribute {0} route-map'.format(protocol)),
             }
         })
 
     # Get redistribute
     for protocol in conf.list_nodes('redistribute'):
         rip_conf['rip']['redist'].update({
             protocol : {
                 'metric' : conf.return_value('redistribute {0} metric'.format(protocol)),
                 'route_map' : conf.return_value('redistribute {0} route-map'.format(protocol)),
             }
         })
 
     conf.set_level(base)
 
     # Get route
     if conf.exists_effective('route'):
         rip_conf['old_rip']['route'] = conf.return_effective_values('route')
 
     if conf.exists('route'):
         rip_conf['rip']['route'] = conf.return_values('route')
 
     # Get timers garbage
     if conf.exists_effective('timers garbage-collection'):
         rip_conf['old_rip']['timer_garbage'] = conf.return_effective_value('timers garbage-collection')
 
     if conf.exists('timers garbage-collection'):
         rip_conf['rip']['timer_garbage'] = conf.return_value('timers garbage-collection')
 
     # Get timers timeout
     if conf.exists_effective('timers timeout'):
         rip_conf['old_rip']['timer_timeout'] = conf.return_effective_value('timers timeout')
 
     if conf.exists('timers timeout'):
         rip_conf['rip']['timer_timeout'] = conf.return_value('timers timeout')
 
     # Get timers update
     if conf.exists_effective('timers update'):
         rip_conf['old_rip']['timer_update'] = conf.return_effective_value('timers update')
 
     if conf.exists('timers update'):
         rip_conf['rip']['timer_update'] = conf.return_value('timers update')
 
     return rip_conf
 
 def verify(rip):
     if rip is None:
         return None
 
     # Check for network. If network-distance acl is set and distance not set
     for net in rip['rip']['net_distance']:
         if not rip['rip']['net_distance'][net]['distance']:
             raise ConfigError(f"Must specify distance for network {net}")
 
 def generate(rip):
     if rip is None:
         return None
 
     render(config_file, 'frr/rip.frr.tmpl', rip)
     return None
 
 def apply(rip):
     if rip is None:
         return None
 
     if os.path.exists(config_file):
         call(f'vtysh -d ripd -f {config_file}')
+        call('sudo vtysh --writeconfig --noerror')
         os.remove(config_file)
     else:
         print("File {0} not found".format(config_file))
 
 
     return None
 
 if __name__ == '__main__':
     try:
         c = get_config()
         verify(c)
         generate(c)
         apply(c)
     except ConfigError as e:
         print(e)
         exit(1)