From: Guus Sliepen Date: Thu, 18 Oct 2018 14:10:32 +0000 (+0200) Subject: Use the onlink flag when adding routes on Linux. X-Git-Tag: release-1.1pre18~49 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=5f76bc06fba1d4ab1cfa460fff5c2695e21cabae;p=tinc Use the onlink flag when adding routes on Linux. As reported by iczero, adding gateway routes on Linux can fail if the gateway address is not reachable yet, either because the interface is down, or if the gateway address is not inside any route that already is added or is being added to that interface. By adding the onlink flag, iproute2 will just add the route without questions. --- diff --git a/src/ifconfig.c b/src/ifconfig.c index 5f614618..76092a7b 100644 --- a/src/ifconfig.c +++ b/src/ifconfig.c @@ -199,11 +199,11 @@ void ifconfig_route(FILE *out, const char *value) { if(*gateway_str) { switch(subnet.type) { case SUBNET_IPV4: - fprintf(out, "ip route add %s via %s dev \"$INTERFACE\"\n", subnet_str, gateway_str); + fprintf(out, "ip route add %s via %s dev \"$INTERFACE\" onlink\n", subnet_str, gateway_str); break; case SUBNET_IPV6: - fprintf(out, "ip route add %s via %s dev \"$INTERFACE\"\n", subnet_str, gateway_str); + fprintf(out, "ip route add %s via %s dev \"$INTERFACE\" onlink\n", subnet_str, gateway_str); break; default: