From 5f76bc06fba1d4ab1cfa460fff5c2695e21cabae Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 18 Oct 2018 16:10:32 +0200 Subject: [PATCH] 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. --- src/ifconfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: -- 2.20.1