From 8526c3f680e3e09c45e91e7fbccaed375d3f3412 Mon Sep 17 00:00:00 2001 From: Maciej Date: Fri, 1 Jul 2022 17:26:14 +0200 Subject: [PATCH] NetworkServer: Clear default gateway route entry before adding --- Userland/Services/NetworkServer/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Services/NetworkServer/main.cpp b/Userland/Services/NetworkServer/main.cpp index f20299c842..a398b9794b 100644 --- a/Userland/Services/NetworkServer/main.cpp +++ b/Userland/Services/NetworkServer/main.cpp @@ -73,8 +73,10 @@ ErrorOr serenity_main(Main::Arguments) // FIXME: Do this asynchronously dbgln("Setting up interface {} statically ({}/{})", ifname, config.ipv4_address, config.ipv4_netmask); MUST(Core::command("ifconfig", { "-a", ifname.characters(), "-i", config.ipv4_address.characters(), "-m", config.ipv4_netmask.characters() }, {})); - if (config.ipv4_gateway != "0.0.0.0") + if (config.ipv4_gateway != "0.0.0.0") { + MUST(Core::command("route", { "del", "-n", "0.0.0.0", "-m", "0.0.0.0", "-i", ifname }, {})); MUST(Core::command("route", { "add", "-n", "0.0.0.0", "-m", "0.0.0.0", "-g", config.ipv4_gateway, "-i", ifname }, {})); + } } } });