diff --git a/clients/cloud-setup/main.c b/clients/cloud-setup/main.c index 9fa4cd3c84..b2b2eabe76 100644 --- a/clients/cloud-setup/main.c +++ b/clients/cloud-setup/main.c @@ -347,11 +347,13 @@ _nmc_mangle_connection(NMDevice * device, if (entry) g_ptr_array_add(addrs_new, entry); } - - gateway = nm_utils_ip4_address_clear_host_address(config_data->cidr_addr, - config_data->cidr_prefix); - ((guint8 *) &gateway)[3] += 1; - + if (config_data->has_gateway && config_data->gateway) { + gateway = config_data->gateway; + } else { + gateway = nm_utils_ip4_address_clear_host_address(config_data->cidr_addr, + config_data->cidr_prefix); + ((guint8 *) &gateway)[3] += 1; + } rt_metric = 10; rt_table = 30400 + config_data->iface_idx; diff --git a/clients/cloud-setup/nmcs-provider.h b/clients/cloud-setup/nmcs-provider.h index 261f589f2f..3663205964 100644 --- a/clients/cloud-setup/nmcs-provider.h +++ b/clients/cloud-setup/nmcs-provider.h @@ -23,9 +23,11 @@ typedef struct { gssize iface_idx; in_addr_t cidr_addr; + in_addr_t gateway; guint8 cidr_prefix; bool has_ipv4s : 1; bool has_cidr : 1; + bool has_gateway : 1; NMIPRoute **iproutes_arr; gsize iproutes_len;