cloudbase / cloudbase-init

Cross-platform instance initialization
http://openstack.org
Apache License 2.0
414 stars 150 forks source link

static routes added are not persistent #55

Closed 10fish closed 4 years ago

10fish commented 4 years ago

I added some routes(e.g. 169.254.169.254) with method:

_cloudbaseinit.os_utils.windows.WindowsUtils.add_staticroute

and found that routes added disappeared after system rebooted or link/bond disabled.

It seems that the method does not support persistent static route rules?

def add_static_route(self, destination, mask, next_hop, interface_index,
                         metric):
        args = ['ROUTE', 'ADD', destination, 'MASK', mask, next_hop]
        (out, err, ret_val) = self.execute_process(args)
        # Cannot use the return value to determine the outcome
        if ret_val or err:
            raise exception.CloudbaseInitException(
                'Unable to add route: %s' % err)

Is there a way with a '-p' option to achieve persistent static route rules?

ader1990 commented 4 years ago

Hello,

Method add_static_route command is used only for temporarily adding the metadata route, so that cloudbase-init can reach it. If you are using the method for your own purpose, you can rewrite it at your own will.

By adding the "/p" flag, the route is persistent, see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/route_ws2008

Thank you, Adrian Vladu

10fish commented 4 years ago

Hi Adrian,

It should solve my problem. Thanks for your solution.