From 2e035ae042ab4557c27953c3a1fd04754c89158a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 7 Jan 2013 15:04:19 +0100 Subject: [PATCH] Hack to prevent -cfg.service from breaking the default gateway Restarting -cfg.service may cause the interface's IP addresses to be flushed. If the default gateway goes through that interface, then the default gateway is deleted. So we need to restart network-setup.target. --- modules/tasks/network-interfaces.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index bbc357b1b29..82f4d3da4f1 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -347,6 +347,9 @@ in echo "configuring interface..." ip -4 addr flush dev "${i.name}" ip -4 addr add "${i.ipAddress}/${mask}" dev "${i.name}" + # Ensure that the default gateway remains set. + # (Flushing this interface may have removed it.) + ${config.system.build.systemd}/bin/systemctl try-restart --no-block network-setup.service else echo "skipping configuring interface" fi