diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 640a1e1bfe..f7c3e07466 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -210,6 +210,22 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) } } + /* If there is a host route to the gateway, ignore that route. It is + * automatically added by NetworkManager when needed. + */ + if (has_gateway) { + for (i = 0; i < priv->routes->len; i++) { + const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i); + + if ( (route->plen == 32) + && (route->network == priv->gateway) + && (route->gateway == 0)) { + g_array_remove_index (priv->routes, i); + i--; + } + } + } + /* If the interface has the default route, and has IPv4 addresses, capture * nameservers from /etc/resolv.conf. */ diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 6319dbf316..083f215810 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -212,6 +212,22 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf) } } + /* If there is a host route to the gateway, ignore that route. It is + * automatically added by NetworkManager when needed. + */ + if (has_gateway) { + for (i = 0; i < priv->routes->len; i++) { + const NMPlatformIP6Route *route = &g_array_index (priv->routes, NMPlatformIP6Route, i); + + if ( route->plen == 128 + && IN6_ARE_ADDR_EQUAL (&route->network, &priv->gateway) + && IN6_IS_ADDR_UNSPECIFIED (&route->gateway)) { + g_array_remove_index (priv->routes, i); + i--; + } + } + } + /* If the interface has the default route, and has IPv4 addresses, capture * nameservers from /etc/resolv.conf. */