]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
dhcpcd.exe: Add a safety net to make sure we always have a route
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Dec 2022 17:23:14 +0000 (17:23 +0000)
committerPeter Müller <peter.mueller@ipfire.org>
Sat, 17 Dec 2022 17:20:46 +0000 (17:20 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/networking/dhcpcd.exe

index 4ab9fbc43031e0cc3183eccca9aef84d27e7a75e..220f95c838d9ef2f598ecfcc11100c4c2998bc01 100644 (file)
@@ -60,6 +60,18 @@ dhcpcd_up()
                mv /tmp/hosts /etc/hosts
        fi
 
+       # Try to set the default route if there is none
+       # This can happen when we are using the 3RD party configuration
+       # This should not be necessary, since dhcpcd says it will configure
+       # a default route, but that does not seem to happen:
+       # https://github.com/NetworkConfiguration/dhcpcd/issues/129
+       if ! ip route 2>/dev/null | grep ^default && [ -s "/var/ipfire/red/remote-ipaddress" ]; then
+               gateway=$(</var/ipfire/red/remote-ipaddress)
+
+               # XXX This is ignoring any MTU configuration
+               ip route add default via "${gateway}"
+       fi
+
        if [ $update ]; then
                # Consider RED being active
                touch /var/ipfire/red/active