diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2024-07-17 08:55:39 +0200 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2024-07-17 09:50:25 +0200 |
| commit | ee2c718c9728d8aed9a014a57223fbd5ba8df5e9 (patch) | |
| tree | 011cf5f97f9595f898084dc7e662c33f71ac94dd /config | |
| parent | 607f2bd9f6422d5a448471a9bfc899eacabff1a6 (diff) | |
networking: replace dummy interface hack with ifplugd service
Diffstat (limited to 'config')
| -rw-r--r-- | config/networking/bridges.nix | 15 | ||||
| -rw-r--r-- | config/networking/default.nix | 2 | ||||
| -rw-r--r-- | config/networking/services/default.nix | 7 | ||||
| -rw-r--r-- | config/networking/services/ifplugd.nix | 37 |
4 files changed, 40 insertions, 21 deletions
diff --git a/config/networking/bridges.nix b/config/networking/bridges.nix index d8cd9e7..e423e03 100644 --- a/config/networking/bridges.nix +++ b/config/networking/bridges.nix @@ -12,21 +12,6 @@ in { sleep 3 ''); } - { - # create a bridge on top of enp3s0 along with a dummy interface - # for kea to work even when enp3s0 is disconnected - # if you change this, you may want to change: - # - the kea configuration in ./services/dhcp.nix - # - the eth0 net configuration ./default.nix - networking = { - bridges.eth0.interfaces = ["enp3s0" "enp3s0-dummy"]; - localCommands = '' - ip link add enp3s0-dummy type dummy - ''; - }; - boot.kernelModules = ["dummy"]; - systemd.services.network-addresses-enp3s0-dummy.enable = false; - } ] ++ (builtins.map (network: let bridge = network.interface; diff --git a/config/networking/default.nix b/config/networking/default.nix index 7ffc32b..81efaf2 100644 --- a/config/networking/default.nix +++ b/config/networking/default.nix @@ -95,7 +95,7 @@ in { }; eth0 = { device = "enp3s0"; - interface = "eth0"; + interface = "enp3s0"; subnet = "192.168.4"; machines = { self.ip = "192.168.4.1"; diff --git a/config/networking/services/default.nix b/config/networking/services/default.nix index 0ec9540..623a1c7 100644 --- a/config/networking/services/default.nix +++ b/config/networking/services/default.nix @@ -1,6 +1,3 @@ -{ ... }: - -{ - imports = - [ ./ap.nix ./dhcp.nix ./dns.nix ./firewall ./igmpproxy.nix ]; +{...}: { + imports = [./ap.nix ./dhcp.nix ./dns.nix ./firewall ./ifplugd.nix ./igmpproxy.nix]; } diff --git a/config/networking/services/ifplugd.nix b/config/networking/services/ifplugd.nix new file mode 100644 index 0000000..4933b97 --- /dev/null +++ b/config/networking/services/ifplugd.nix @@ -0,0 +1,37 @@ +{ + config, + pkgs, + ... +}: let + iface = config.personal.networking.networks.eth0.device; + dhcpService = "kea-dhcp4-server.service"; + action = pkgs.writeShellApplication { + name = "ifplugd-enp3s0.action"; + runtimeInputs = [pkgs.systemd]; + text = '' + INTERFACE="$1" + EVENT="$2" + + if [[ "$INTERFACE" == '${iface}' && "$EVENT" == up ]] + then + echo ${iface} went up, restarting ${dhcpService}... + systemctl restart ${dhcpService} + fi + ''; + }; +in { + systemd.services."ifplugd-${iface}" = { + enable = true; + + description = "Monitor status of interface ${iface}"; + after = ["sys-subsystem-net-devices-${iface}.device" dhcpService]; + wantedBy = [dhcpService]; + + script = '' + # iface no-daemon no-auto no-shutdown delay-up run + ifplugd -i ${iface} -n -a -q -u 5 -r \ + ${action}/bin/ifplugd-enp3s0.action + ''; + path = [pkgs.busybox]; + }; +} |
